Skip to content

Commit

Permalink
Enhance TLS handshake error messages with connection information
Browse files Browse the repository at this point in the history
fixes #12287
  • Loading branch information
Michael Friedrich committed Aug 2, 2016
1 parent 7341727 commit b7da28b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/remote/apilistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,33 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
{
CONTEXT("Handling new API client connection");

String conninfo;

if (role == RoleClient)
conninfo = "to";
else
conninfo = "from";

conninfo += " " + client->GetPeerAddress();

TlsStream::Ptr tlsStream;

{
ObjectLock olock(this);
try {
tlsStream = new TlsStream(client, hostname, role, m_SSLContext);
} catch (const std::exception&) {
Log(LogCritical, "ApiListener", "Cannot create TLS stream from client connection.");
Log(LogCritical, "ApiListener")
<< "Cannot create TLS stream from client connection (" << conninfo << ")";
return;
}
}

try {
tlsStream->Handshake();
} catch (const std::exception& ex) {
Log(LogCritical, "ApiListener", "Client TLS handshake failed");
Log(LogCritical, "ApiListener")
<< "Client TLS handshake failed (" << conninfo << ")";
return;
}

Expand All @@ -330,15 +341,6 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
Endpoint::Ptr endpoint;
bool verify_ok = false;

String conninfo;

if (role == RoleClient)
conninfo = "to";
else
conninfo = "from";

conninfo += " " + client->GetPeerAddress();

if (cert) {
try {
identity = GetCertificateCN(cert);
Expand Down

0 comments on commit b7da28b

Please sign in to comment.