Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/backend/nvhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,17 @@ NvHTTP::openConnection(QUrl baseUrl,
connectTimer->start(REQUEST_TIMEOUT_MS);
#endif

// sslErrors() is only emitted when the host's certificate fails validation, so
// handleSslErrors() never sees a certificate that chains to a CA trusted by the
// system. Check the pinned certificate here too. This signal is emitted after the
// TLS handshake but before our request (and its query parameters) is sent.
connect(reply, &QNetworkReply::encrypted, reply, [this, reply]() {
if (reply->sslConfiguration().peerCertificate() != m_ServerCert) {
reply->setProperty("cert_mismatch", true);
reply->abort();
}
});

if (logLevel >= NvLogLevel::NVLL_VERBOSE) {
qInfo() << "Executing request:" << url.toString();
}
Expand Down Expand Up @@ -575,7 +586,7 @@ NvHTTP::openConnection(QUrl baseUrl,
qWarning() << command << "request failed with error:" << reply->error();
}

if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
if (reply->error() == QNetworkReply::SslHandshakeFailedError || reply->property("cert_mismatch").toBool()) {
// This will trigger falling back to HTTP for the serverinfo query
// then pairing again to get the updated certificate.
GfeHttpResponseException exception(401, "Server certificate mismatch");
Expand Down