c++qtsslopenssl

Qt error message "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed"


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

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));
    }
}

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:

Did I miss something?

Edit:

Thanks for the reply:

Here is what is get from the qDebugs:

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.

Installation folder content:

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


Solution

  • Here is the solution (that worked for me):