diff options
author | Simon Rettberg | 2017-11-16 14:21:23 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-16 14:21:23 +0100 |
commit | 0d3d853f8414bd383fa1caea8a9322cb7854e5f3 (patch) | |
tree | b775b745b8497ab520ab41e2c0ca2b2f1f61712a /src/client | |
parent | fix qresource precompilation with cmake (diff) | |
download | pvs2-0d3d853f8414bd383fa1caea8a9322cb7854e5f3.tar.gz pvs2-0d3d853f8414bd383fa1caea8a9322cb7854e5f3.tar.xz pvs2-0d3d853f8414bd383fa1caea8a9322cb7854e5f3.zip |
Fix SSL on Qt5
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/net/serverconnection.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index e9cc72c..d79c7c3 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -33,7 +33,9 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons this, SLOT(sslErrors(const QList<QSslError> &)) ); + connect(_socket, &QSslSocket::peerVerifyError, [=](const QSslError &error) { qDebug() << "PVE:" << error.errorString(); }); qDebug("Connecting to %s on port %d", host.toUtf8().data(), (int)port); + _socket->ignoreSslErrors(); _socket->connectToHostEncrypted(host, port); _timerId = startTimer(4000); _lastData = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS; @@ -294,10 +296,12 @@ void ServerConnection::timerEvent(QTimerEvent *event) { if (event->timerId() == _timerConnectionCheck) { if (_lastData < QDateTime::currentMSecsSinceEpoch()) { + qDebug() << "Ping timeout"; this->disconnectFromServer(); killTimer(_timerConnectionCheck); } } else if (event->timerId() == _timerId) { + qDebug() << "Connect timeout"; killTimer(_timerId); _timerId = 0; this->disconnectFromServer(); @@ -362,7 +366,7 @@ void ServerConnection::onVncViewerStartStop(const bool started, const int client void ServerConnection::sslErrors(const QList<QSslError> & errors) { for (QList<QSslError>::const_iterator it = errors.begin(); it != errors.end(); it++) { - QSslError err = *it; + const QSslError &err = *it; qDebug("Connect SSL: %s", qPrintable(err.errorString())); if (err.error() == QSslError::HostNameMismatch) continue; // We don't pay attention to hostnames for validation @@ -371,9 +375,9 @@ void ServerConnection::sslErrors(const QList<QSslError> & errors) if (err.error() == QSslError::CertificateNotYetValid || err.error() == QSslError::CertificateExpired) continue; // Some other SSL error - do not ignore + _socket->ignoreSslErrors(QList<QSslError>()); return; } - _socket->ignoreSslErrors(); } void ServerConnection::sock_dataArrival() @@ -416,6 +420,7 @@ void ServerConnection::sock_error(QAbstractSocket::SocketError errcode) void ServerConnection::sock_connected() { + qDebug() << "Connection to server established and encrypted"; QByteArray cert(_socket->peerCertificate().digest(QCryptographicHash::Sha1)); if (_certHash != cert) { emit stateChange(ConnectWindow::InvalidCert); |