Skip to content

Commit

Permalink
Listener: Fixed misleading logged error message on TLS handshake
Browse files Browse the repository at this point in the history
The default error messages in the Network domain call the peer
"server" and the local process "client", which is backwards.
This results in misleading error logs when a TLS handshake fails,
like "server rejected the client TLS certificate" when actually it's
the other way around!
Fixed this by simply swapping the strings "client" and "server" when
logging errors in the Network domain when establishing a connection.
  • Loading branch information
snej committed Nov 5, 2024
1 parent 17b1491 commit c18b18a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions REST/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ namespace litecore::REST {
void Server::handleConnection(sockpp::stream_socket&& sock) {
auto responder = make_unique<ResponderSocket>(_tlsContext);
if ( !responder->acceptSocket(std::move(sock)) || (_tlsContext && !responder->wrapTLS()) ) {
c4log(ListenerLog, kC4LogError, "Error accepting incoming connection: %s",
responder->error().description().c_str());
C4Error error = responder->error();
string description = error.description();
if (error.domain == NetworkDomain) {
// The default messages call the peer "server" and me "client"; reverse that:
replace(description, "server", "CLIENT");
replace(description, "client", "server");
replace(description, "CLIENT", "client");
}
c4log(ListenerLog, kC4LogError, "Error accepting incoming connection: %s", description.c_str());
return;
}

Expand Down

0 comments on commit c18b18a

Please sign in to comment.