Qt错误消息"qt.network.ssl:QSslSocket :: connectToHostEncrypted:TLS初始化失败" [英] Qt error message "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed"

查看:128
本文介绍了Qt错误消息"qt.network.ssl:QSslSocket :: connectToHostEncrypted:TLS初始化失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试运行Qt应用程序时出现以下错误:

I get the following error when I try to run my Qt application:

qt.network.ssl:QSslSocket :: connectToHostEncrypted:TLS初始化失败
qt.network.ssl:QSslSocket :: connectToHostEncrypted:TLS初始化失败
错误:"TLS初始化失败"

qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
Error: "TLS initialization failed"

我的应用程序真的很基础,这是它的外观:

My application is really basic here is what it is look like:

#include "widget.h"
#include "ui_widget.h"
#include <QNetworkReply>

#include <QDebug>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    netManager  = new QNetworkAccessManager(this);
    netReply = nullptr;
    mDataBuffer = new QByteArray();

    //Define network request
    QNetworkRequest request;
    request.setUrl(QUrl("https://www.qt.io"));

    netReply = netManager->get(request);
    connect(netReply,&QIODevice::readyRead,this,&Widget::dataReadyToRead);
    connect(netReply,&QNetworkReply::finished,this,&Widget::dataReadFinished);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::dataReadyToRead()
{
    qDebug() << "Datas available to read";
    mDataBuffer->append(netReply->readAll());
}

void Widget::dataReadFinished()
{
    if(netReply->error())
    {
        qDebug() << "Error: " << netReply->errorString();
    }
    else
    {
        ui->textEdit->setPlainText(QString(*mDataBuffer));
    }
}

所以我搜索了堆栈溢出并找到了一些答案(似乎由于未找到openSSl库,所以发生了错误),但是它仍然不起作用.
所以这是我到目前为止所做的:

So I searched on stack overflow and find some answers (it seems that the error occurs because the openSSl librairies are not found) but it still doesn't work.
So here is what I've done so far:

  • 我已经在以下网站上下载了64位窗口的OpenSSL(Win64 OpenSSL v1.1.1d): https://slproweb.com/products/Win32OpenSSL.html
  • 我已经安装了OpenSSL(-尝试设置环境变量,但我没有正确地做到这一点)
  • 尝试在运行openSSL时运行我的应用

我错过了什么吗?

感谢您的答复:

这是从qDebug中得到的东西:

Here is what is get from the qDebugs:

  • QSslSocket :: sslLibraryBuildVersionString()返回:"OpenSSL 1.0.2p 2018年8月14日"

  • QSslSocket::sslLibraryBuildVersionString() returned: "OpenSSL 1.0.2p 14 Aug 2018"

QSslSocket :: supportsSsl()返回:false

QSslSocket::supportsSsl() returned: false

QSslSocket :: sslLibraryVersionString()返回:空字符串

QSslSocket::sslLibraryVersionString() returned: an empty string

因此,这里是我抓取并安装了1.0.2版本的OpenSSL(取消安装另一个版本),将安装文件夹添加到PATH变量中(简单地为C:\ OpenSSL-Win64,也尝试了C:\OpenSSL-Win64 \ bin这两个文件都包含dll)

So here is I've grab and install OpenSSL in 1.0.2 version, (unistall the other one), add to the PATH variable the install folder (which is simply C:\OpenSSL-Win64, also tried C:\OpenSSL-Win64\bin both of those file cotains dll)

不幸的是,我仍然遇到同样的问题.

Unfortunately I still have the same problem.

安装文件夹内容:

  • bin
  • exp
  • 包括
  • lib
  • changes.txt
  • faq.txt
  • libeay32.dll
  • libssl.dll
  • license.txt
  • news.txt
  • readme.txt
  • ssleay32.dll
  • unins000.dat
  • unins000.exe

现在,我在阅读Qt文档后尝试做一些事情: https://doc.qt.io/qt-5/windows-requirements.html

Now I've tried to do somethings after I've read Qt documentation: https://doc.qt.io/qt-5/windows-requirements.html

  • 我将目录OpenSSL-Win64复制/粘贴到C:\ Windows \ System32中(根据文档,首先在此目录中查找openSSL库)->无效
  • 我已经创建了一个PATH环境变量,并为其提供了openSSL安装文件夹的值(目前,我使用了默认情况下创建的"Path"环境变量,它已经覆盖了默认值,但我设法恢复它)->无效

推荐答案

以下是解决方案(对我有用):

Here is the solution (that worked for me):

  • 使用qDebug检查哪个版本的OpenSSL用于Qt构建(请参见Fareanor答案).
  • 因为它是我的操作系统,所以下载Windows 64位版OpenSSl的关闭版本.
  • 执行下载的安装程序,并选中将OpenSSL DLL复制到:Windows系统目录"复选框.

这篇关于Qt错误消息"qt.network.ssl:QSslSocket :: connectToHostEncrypted:TLS初始化失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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