Browse code

tls: better log messages when failing to create ssl ctx

Daniel-Constantin Mierla authored on 26/05/2020 13:05:15
Showing 1 changed files
... ...
@@ -1036,7 +1036,11 @@ static int ksr_tls_fix_domain(tls_domain_t* d, tls_domain_t* def)
1036 1036
 			d->ctx[i] = SSL_CTX_new((SSL_METHOD*)ssl_methods[d->method - 1]);
1037 1037
 		}
1038 1038
 		if (d->ctx[i] == NULL) {
1039
-			ERR("%s: Cannot create SSL context\n", tls_domain_str(d));
1039
+			unsigned long e = 0;
1040
+			e = ERR_peek_last_error();
1041
+			ERR("%s: Cannot create SSL context [%d] (%lu: %s / %s)\n",
1042
+					tls_domain_str(d), i, e, ERR_error_string(e, NULL),
1043
+					ERR_reason_error_string(e));
1040 1044
 			return -1;
1041 1045
 		}
1042 1046
 		if(d->method>TLS_USE_TLSvRANGE) {
... ...
@@ -1046,7 +1050,11 @@ static int ksr_tls_fix_domain(tls_domain_t* d, tls_domain_t* def)
1046 1050
 		/* libssl >= 1.1.0 */
1047 1051
 		d->ctx[i] = SSL_CTX_new(sr_tls_methods[d->method - 1].TLSMethod);
1048 1052
 		if (d->ctx[i] == NULL) {
1049
-			ERR("%s: Cannot create SSL context\n", tls_domain_str(d));
1053
+			unsigned long e = 0;
1054
+			e = ERR_peek_last_error();
1055
+			ERR("%s: Cannot create SSL context [%d] (%lu: %s / %s)\n",
1056
+					tls_domain_str(d), i, e, ERR_error_string(e, NULL),
1057
+					ERR_reason_error_string(e));
1050 1058
 			return -1;
1051 1059
 		}
1052 1060
 		if(d->method>TLS_USE_TLSvRANGE) {