Merge PR #516: Fix encryption flag erraneously set for "ws" connections

This commit is contained in:
Jenkins nymea 2021-01-23 20:30:20 +01:00
commit 0c1b4dac51
3 changed files with 7 additions and 6 deletions

View File

@ -250,7 +250,7 @@ void NymeaConnection::onConnected()
NymeaTransportInterface* newTransport = qobject_cast<NymeaTransportInterface*>(sender()); NymeaTransportInterface* newTransport = qobject_cast<NymeaTransportInterface*>(sender());
if (!m_currentTransport) { if (!m_currentTransport) {
m_currentTransport = newTransport; m_currentTransport = newTransport;
qDebug() << "NymeaConnection: Connected to" << m_currentHost->name() << "via" << m_currentTransport->url(); qDebug() << "NymeaConnection: Connected to" << m_currentHost->name() << "via" << m_currentTransport->url() << m_currentTransport->isEncrypted();
emit currentConnectionChanged(); emit currentConnectionChanged();
emit connectedChanged(true); emit connectedChanged(true);
return; return;

View File

@ -101,7 +101,7 @@ void WebsocketTransport::ignoreSslErrors(const QList<QSslError> &errors)
bool WebsocketTransport::isEncrypted() const bool WebsocketTransport::isEncrypted() const
{ {
return !m_socket->sslConfiguration().isNull(); return m_url.scheme() == "wss";
} }
QSslCertificate WebsocketTransport::serverCertificate() const QSslCertificate WebsocketTransport::serverCertificate() const

View File

@ -665,14 +665,15 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap &params)
if (m_connection->sslCertificate().toPem() != pem) { if (m_connection->sslCertificate().toPem() != pem) {
// Uh oh, the certificate has changed // Uh oh, the certificate has changed
qWarning() << "This connections certificate has changed!"; qWarning() << "This connections certificate has changed!";
qWarning() << "Old PEM:" << pem;
QSslCertificate certificate = m_connection->sslCertificate(); qWarning() << "New PEM:" << m_connection->sslCertificate().toPem();
QVariantMap issuerInfo = certificateIssuerInfo();
emit verifyConnectionCertificate(m_serverUuid, issuerInfo, certificate.toPem());
// Reject the connection until the UI explicitly accepts this... // Reject the connection until the UI explicitly accepts this...
m_connection->disconnectFromHost(); m_connection->disconnectFromHost();
QSslCertificate certificate = m_connection->sslCertificate();
QVariantMap issuerInfo = certificateIssuerInfo();
emit verifyConnectionCertificate(m_serverUuid, issuerInfo, certificate.toPem());
return; return;
} }
qDebug() << "This connections certificate is trusted."; qDebug() << "This connections certificate is trusted.";