From 1e98594972397ca58d249562b3b93e2a54ef0812 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 21 Dec 2018 19:16:33 -0800 Subject: [PATCH] Handle server cert change by pairing again --- app/backend/nvhttp.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index c9a08001..edb6095c 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -434,9 +434,19 @@ NvHTTP::openConnection(QUrl baseUrl, if (logLevel >= NvLogLevel::ERROR) { qWarning() << command << " request failed with error " << reply->error(); } - QtNetworkReplyException exception(reply->error(), reply->errorString()); - delete reply; - throw exception; + + if (!m_ServerCert.isNull() && reply->error() == QNetworkReply::SslHandshakeFailedError) { + // 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"); + delete reply; + throw exception; + } + else { + QtNetworkReplyException exception(reply->error(), reply->errorString()); + delete reply; + throw exception; + } } return reply;