From e388d46bc6191e746984a9254f4ac243689f31d2 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 20 Mar 2020 10:18:29 +0100 Subject: [PATCH] Add better error reporting if SSL fails to establish a connection --- libnymea-core/servers/tcpserver.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libnymea-core/servers/tcpserver.cpp b/libnymea-core/servers/tcpserver.cpp index 2269e6de..d54294db 100644 --- a/libnymea-core/servers/tcpserver.cpp +++ b/libnymea-core/servers/tcpserver.cpp @@ -233,6 +233,13 @@ void SslServer::incomingConnection(qintptr socketDescriptor) connect(sslSocket, &QSslSocket::encrypted, [this, sslSocket](){ emit clientConnected(sslSocket); }); connect(sslSocket, &QSslSocket::readyRead, this, &SslServer::onSocketReadyRead); connect(sslSocket, &QSslSocket::disconnected, this, &SslServer::onClientDisconnected); + typedef void (QSslSocket:: *sslErrorsSignal)(const QList &); + connect(sslSocket, static_cast(&QSslSocket::sslErrors), this, [](const QList &errors) { + qCWarning(dcTcpServer()) << "SSL Errors happened in the client connections:"; + foreach (const QSslError &error, errors) { + qCWarning(dcTcpServer()) << "SSL Error:" << error.error() << error.errorString(); + } + }); if (!sslSocket->setSocketDescriptor(socketDescriptor)) { qCWarning(dcTcpServer()) << "Failed to set SSL socket descriptor."; @@ -240,6 +247,7 @@ void SslServer::incomingConnection(qintptr socketDescriptor) return; } if (m_sslEnabled) { + qCDebug(dcTcpServer()) << "Starting SSL encryption"; sslSocket->setSslConfiguration(m_config); sslSocket->startServerEncryption(); } else {