Skip to content

Commit fb81728

Browse files
kn71026marty1885
andauthored
Clarify SSL error message (#214)
Co-authored-by: Martin Chang <marty1885@users.noreply.github.com>
1 parent bbcc0ac commit fb81728

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ std::shared_ptr<SSLContext> newSSLServerContext(
298298
if (!r)
299299
{
300300
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
301-
LOG_FATAL << "Reading certificate: " << errbuf;
301+
LOG_FATAL << "Reading certificate: " << certPath
302+
<< " failed. Error: " << errbuf;
302303
throw std::runtime_error("SSL_CTX_use_certificate_chain_file error.");
303304
}
304305
r = SSL_CTX_use_PrivateKey_file(ctx->get(),
@@ -307,14 +308,16 @@ std::shared_ptr<SSLContext> newSSLServerContext(
307308
if (!r)
308309
{
309310
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
310-
LOG_FATAL << "Reading private key: " << errbuf;
311+
LOG_FATAL << "Reading private key: " << keyPath
312+
<< " failed. Error: " << errbuf;
311313
throw std::runtime_error("SSL_CTX_use_PrivateKey_file error");
312314
}
313315
r = SSL_CTX_check_private_key(ctx->get());
314316
if (!r)
315317
{
316318
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
317-
LOG_FATAL << "Checking private key matches certificate: " << errbuf;
319+
LOG_FATAL << "Checking private key matches certificate: " << certPath
320+
<< " and " << keyPath << " mismatches. Error: " << errbuf;
318321
throw std::runtime_error("SSL_CTX_check_private_key error");
319322
}
320323

@@ -359,7 +362,8 @@ std::shared_ptr<SSLContext> newSSLClientContext(
359362
if (!r)
360363
{
361364
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
362-
LOG_FATAL << "Reading certificate: " << errbuf;
365+
LOG_FATAL << "Reading certificate: " << certPath
366+
<< " failed. Error: " << errbuf;
363367
throw std::runtime_error("SSL_CTX_use_certificate_chain_file error.");
364368
}
365369
r = SSL_CTX_use_PrivateKey_file(ctx->get(),
@@ -368,15 +372,17 @@ std::shared_ptr<SSLContext> newSSLClientContext(
368372
if (!r)
369373
{
370374
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
371-
LOG_FATAL << "Reading private key: " << errbuf;
372-
throw std::runtime_error("SSL_CTX_use_PrivateKey_file error.");
375+
LOG_FATAL << "Reading private key: " << keyPath
376+
<< " failed. Error: " << errbuf;
377+
throw std::runtime_error("SSL_CTX_use_PrivateKey_file error");
373378
}
374379
r = SSL_CTX_check_private_key(ctx->get());
375380
if (!r)
376381
{
377382
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
378-
LOG_FATAL << "Checking private key matches certificate: " << errbuf;
379-
throw std::runtime_error("SSL_CTX_check_private_key error.");
383+
LOG_FATAL << "Checking private key matches certificate: " << certPath
384+
<< " and " << keyPath << " mismatches. Error: " << errbuf;
385+
throw std::runtime_error("SSL_CTX_check_private_key error");
380386
}
381387

382388
if (!caPath.empty())

0 commit comments

Comments
 (0)