QT QSslError 以错误代码设置为 NoError 发出信号 [英] QT QSslError being signaled with the error code set to NoError

查看:95
本文介绍了QT QSslError 以错误代码设置为 NoError 发出信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题
我将 OpenSSL 编译成 QT 以启用 OpenSSL 支持.一切似乎都在编译中正确进行.

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

但是,当我尝试使用官方 HTTP 示例应用程序时,可以 在这里找到,每次我尝试下载 https 页面时,它都会发出两个 QSslError 信号,每个都包含 NoError 内容.

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.

QSslErrors 的类型,包括 NoError,此处记录,很糟糕.没有解释为什么他们甚至包括一个叫做 NoError 的错误类型,或者它意味着什么.

The types of QSslErrors, including NoError, are documented here, poorly. There is no explanation on why they even included an error type called NoError, or what it means.

奇怪的是,NoError 错误代码似乎是正确的,因为即使发出错误信号,它也能完美下载远程 https 文档.

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

有谁知道这意味着什么以及可能导致它的原因是什么?

可选背景阅读
这是示例应用程序代码的相关部分(这是通过构造函数连接到网络连接的 sslErrors 信号):

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.

我尝试过 OpenSSL 1.0.0a 和 0.9.8o.我试过自己编译 OpenSSL,也试过使用网上预编译版本的 OpenSSL.都产生相同的结果.

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.

如果这是我第一次使用带有 SSL 的 QT,我几乎会认为这是预期的结果(即使他们的示例应用程序弹出错误警告消息窗口),如果不是因为我上次使用 QT,使用现在是旧版本的 QT 和旧版本的 SSL,我清楚地记得一切正常,没有错误窗口.

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.

我的系统运行的是 Windows 7 x64.

My system is running Windows 7 x64.

推荐答案

我收到 4 个错误,超过 3 次.4 个(预期的)错误是:1.主机名与此证书的任何有效主机都不匹配2.本地查找的证书的颁发者证书找不到3.不信任根CA证书用于此目的4.无法验证证书

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

我怀疑您的NoError"指的是最后一个(#4)...

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

我得到 3 次重复的原因似乎是因为有 3 个线程在运行 - 每个线程都触发相同的 sslErrors 信号.

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

我怀疑您的 2 次重复是由于在 WebView 小部件中运行了 2 个线程.

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

这篇关于QT QSslError 以错误代码设置为 NoError 发出信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆