Merge PR #273: Add better error reporting when a client fails to establish the encryption channel

pull/280/head
Jenkins nymea 2020-04-05 14:43:23 +02:00
commit 7c3143a9ea
1 changed files with 8 additions and 0 deletions

View File

@ -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<QSslError> &);
connect(sslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, [](const QList<QSslError> &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 {