[英]QT request https url, ok in windows ko in linux
I have the following code in QT that correctly get the webpage in Windows ( 7 x64 ) but not in Linux Debian 9.13我在 QT 中有以下代码,可以正确获取 Windows ( 7 x64 ) 中的网页,但不能在 Linux Debian 9.13 中获取网页
void Mycl::getdata()
{
QNetworkAccessManager *networkManager;
networkManager = new QNetworkAccessManager(this);
QString urlStr="https://.......");
QUrl url(urlStr);
QNetworkRequest request;
request.setUrl(url);
connect (networkManager,SIGNAL(finished(QNetworkReply*)),this, SLOT(done(QNetworkReply*)));
networkManager->get(request);
}
void Mycl::done(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::NoError)
{
QString data = QString(reply->readAll ());
in Debian i get the folowing error at runtime:在 Debian 中,我在运行时收到以下错误:
Warning: QSslSocket: OpenSSL >= 1.1.1 is required;警告:QSslSocket:需要 OpenSSL >= 1.1.1; OpenSSL 1.1.0l 10 Sep 2019 was found instead ((null):0, (null))
OpenSSL 1.1.0l 2019 年 9 月 10 日改为 ((null):0, (null))
Warning: QSslSocket::connectToHostEncrypted: TLS initialization failed ((null):0, (null))警告:QSslSocket::connectToHostEncrypted:TLS 初始化失败((空):0,(空))
Debug: "TLS initialization failed" (../Shiva2/mycl.cpp:65, void Mycl::done(QNetworkReply*))调试:“TLS 初始化失败”(../Shiva2/mycl.cpp:65,void Mycl::done(QNetworkReply*))
I have the following package installed in the os:我在操作系统中安装了以下 package:
ii libssl1.0.2:amd64 1.0.2u-1~deb9u6 amd64 Secure Sockets Layer toolkit - shared libraries ii libssl1.0.2:amd64 1.0.2u-1~deb9u6 amd64 Secure Sockets 层工具包 - 共享库
ii libssl1.1:amd64 1.1.0l-1~deb9u4 amd64 Secure Sockets Layer toolkit - shared libraries ii libssl1.1:amd64 1.1.0l-1~deb9u4 amd64 Secure Sockets 层工具包 - 共享库
ii libssl-dev:amd64 1.1.0l-1~deb9u4 amd64 Secure Sockets Layer toolkit - development files ii libssl-dev:amd64 1.1.0l-1~deb9u4 amd64 Secure Sockets 层工具包 - 开发文件
ii openssl 1.1.0l-1~deb9u4 amd64 Secure Sockets Layer toolkit - cryptographic utility ii openssl 1.1.0l-1~deb9u4 amd64 Secure Sockets 层工具包 - 加密实用程序
I don't know if the error is related to this packages... any suggestion?我不知道这个错误是否与这个包有关......有什么建议吗? thanks
谢谢
UPDATE: Trying to update packages to debian bullseye ( stable ) I get the following error on a dependency:更新:尝试将包更新到 debian bullseye ( stable ) 我在依赖项上收到以下错误:
dpkg -i libc6_2.31-13+deb11u2_amd64.deb
dpkg: regarding libc6_2.31-13+deb11u2_amd64.deb containing libc6:amd64:
libc6:amd64 breaks locales (<< 2.31)
locales (version 2.24-11+deb9u4) is present and installed.
dpkg: error processing archive libc6_2.31-13+deb11u2_amd64.deb (--install):
installing libc6:amd64 would break locales, and
deconfiguration is not permitted (--auto-deconfigure might help)
Errors were encountered while processing:
libc6_2.31-13+deb11u2_amd64.deb
also i can't upgrade full os cause it's a virtual server in rent.我也无法升级完整的操作系统,因为它是租用的虚拟服务器。 Which version of QT i should use?
我应该使用哪个版本的 QT?
It says that you have to have openssl version 1.1.1 or higher.它说你必须有 openssl 版本 1.1.1 或更高版本。 But Debian 9 out-of-the-box supports only 1.1.0.
但是开箱即用的 Debian 9 只支持 1.1.0。 So you have to either upgrade openssl or downgrade Qt. Here you can find how to upgrade openssl in debian 9.
因此,您必须升级 openssl 或降级 Qt。 在这里,您可以在 debian 9 中找到如何升级 openssl。
And of course you can update your OS but it look like the trickiest way, though.当然,您可以更新您的操作系统,但这看起来是最棘手的方法。 :)
:)
That is due to the openssl version provided by you OS and the one required by QT.这是由于您的操作系统提供的 openssl 版本和 QT 所需的版本。
Avoid up/down-grading your OS openssl version, try connecting to the QNetworkAccessManager signal:避免升级/降级操作系统 openssl 版本,尝试连接到 QNetworkAccessManager 信号:
void QNetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
and, in your slot, invoke reply->ignoreSslErrors()
.并在您的插槽中调用
reply->ignoreSslErrors()
。
If that does not work, copy the QT openssl.so files somewhere in your PATH.如果这不起作用,请将 QT openssl.so 文件复制到您的 PATH 中的某个位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.