dbhub: Ignore errors about self signed certificates in a chain

Previously we'd only ignore errors about a single self signed
certificate but apparently it's an entirely different matter to Qt or
OpenSSL if we're talking about a self signed certificate in a
certificate chain.
This commit is contained in:
Martin Kleusberg
2016-10-26 23:54:41 +02:00
parent e12022432f
commit 19d45bfc54

View File

@@ -96,9 +96,20 @@ void RemoteDatabase::fetchDatabase(const QString& url)
void RemoteDatabase::gotEncrypted(QNetworkReply* reply)
{
// Verify the server's certificate using our CA certs. If it's not good, abort the reply here
// Verify the server's certificate using our CA certs
auto verificationErrors = reply->sslConfiguration().peerCertificate().verify(m_sslConfiguration.caCertificates());
if(!(verificationErrors.size() == 0 || (verificationErrors.size() == 1 && verificationErrors.at(0).error() == QSslError::SelfSignedCertificate)))
bool good = false;
if(verificationErrors.size() == 0)
{
good = true;
} else if(verificationErrors.size() == 1) {
// Ignore any self signed certificate errors
if(verificationErrors.at(0).error() == QSslError::SelfSignedCertificate || verificationErrors.at(0).error() == QSslError::SelfSignedCertificateInChain)
good = true;
}
// If the server certificate didn't turn out to be good, abort the reply here
if(!good)
reply->abort();
}