开发者

QT QSslError being signaled with the error code set to NoError

开发者 https://www.devze.com 2023-01-10 21:48 出处:网络
My Problem I compiled OpenSSL into QT to enable OpenSSL support. Everything appeared to go correctly in the compile.

My Problem

I compiled OpenSSL into QT to enable OpenSSL support. Everything appeared to go correctly in the compile.

However, when I try to use the official HTTP example application that can be found here, everytime I try to download an https page, it will signal two QSslError, each with contents NoError.

The types of QSslErrors, including NoError, are documented here, poorly. There is no explanation on why they even included an error type called NoE开发者_如何学JAVArror, or what it means.

Bizarrely, the NoError error code seems to be true, as it downloads the remote https document perfectly even while signaling the error.

Does anyone have any idea what this means and what could possibly be causing it?

Optional Background Reading

Here is the relevant part of the code from the example app (this is connected to the network connection's sslErrors signal by the constructor):

void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
{
 QString errorString;
 foreach (const QSslError &error, errors) {
     if (!errorString.isEmpty())
         errorString += ", ";
     errorString += error.errorString();
 }

 if (QMessageBox::warning(this, tr("HTTP"),
                          tr("One or more SSL errors has occurred: %1").arg(errorString),
                          QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
     reply->ignoreSslErrors();
 }
}

I have tried the old version of this example, and it produced the same result.

I have tried OpenSSL 1.0.0a and 0.9.8o. I have tried tried compiling OpenSSL myself, I have tried using pre-compiled versions of OpenSSL from the net. All produce the same result.

If this were my first time using QT with SSL, I would almost think this is the intended result (even though their example application is popping up error warning message windows), if not for the fact that last time I played with QT, using what would now be an old version of QT with an old version of SSL, I distinctly remember everything working fine with no error windows.

My system is running Windows 7 x64.


The only path where a QSslError can be constructed with a NoError code is during conversion from OpenSSL error codes to QSslError::SslError values, when the error code is X509_V_OK. There is an interesting note about this error code in the OpenSSL docs:

If no peer certificate was presented, the returned result code is X509_V_OK. This is because no verification error occurred, it does however not indicate success.

Can you check with Wireshark or something similar if the certificate is being transmitted?


I get 4 errors, 3 times over. The 4 (expected) errors are: 1.The host name did not match any of the valid hosts for this certificate 2.The issuer certificate of a locally looked up certificate could not be found 3.The root CA certificate is not trusted for this purpose 4.No certificates could be verified

I suspect your "NoError" refers to the last (#4)...

The reason I got 3 repeats appears to be because there are 3 threads running - each fires the same sslErrors signal.

I suspect your 2 repeats were due to 2 threads running in the WebView widget.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号