Unsolved TLS initialization failed
-
Hello! While I was programming in Qt (on Windows 10) I stuck with a problem:
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
I downloaded 1.1.1d of OpenSSL, also included OpenSSL-Win32 in PATH, then I tried to include
INCLUDEPATH += C:/Program Files (x86)/OpenSSL-Win32/include
And nothing have helped me!
My code:
/... #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkRequest> #include <QtXml/QDomDocument> #include <QtXml/QDomNode> #include <QUrl> /... void log_in::setCurrency() { QNetworkAccessManager *manager = new QNetworkAccessManager(this); QNetworkRequest request(QUrl("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml")); connect(manager, &QNetworkAccessManager::finished, this, &log_in::getResponse); qDebug() << QSslSocket::sslLibraryBuildVersionString(); manager->get(QNetworkRequest(request)); } void log_in::getResponse(QNetworkReply *reply) { QDomDocument domDoc; if(domDoc.setContent(reply->readAll())) { QDomNode rootNode = domDoc.documentElement(); findNode( rootNode, "Cube", "USD"); findNode( rootNode, "Cube", "RUB"); findNode( rootNode, "Cube", "GBP"); } delete reply; } bool log_in::findNode(const QDomNode &node, const QString &name, const QString ¤cy) { if(node.isElement()) { QDomElement element = node.toElement(); if(element.tagName() == name && element.attribute("currency") == currency) { QString str; str.append(node.firstChildElement("currency").text()); str.append(" "); QString str_double(node.firstChildElement("Cube rate").text()); double rate = str_double.toDouble(); str.append(QString::number(rate, 'f', 2)); str.append(" €"); if(currency == "USD") { ui->dollar_currency->setText(str); } else if(currency == "RUB") { ui->rubles_currency->setText(str); } else if(currency == "GBP") { ui->pounds_currency->setText(str); } return true; } } QDomNode siblingNode = node.nextSiblingElement(); while(!siblingNode.isNull()) { bool res = findNode(siblingNode, name, currency); if(res) return true; siblingNode = node.nextSiblingElement(); } QDomNode childNode = node.firstChild(); if(!childNode.isNull()) { bool res = findNode(childNode, name, currency); if(res) return true; } return false; }
I would like to get help from you.
-
Hi and welcome to devnet,
What version of Qt are you using ?
Which compiler are you using ? -
Thank you for welcoming!
I am using Qt 5.12.6 and I am not really sure, but I think I use msvc2017, because I have in my Qt file msvc2017 and mingw73_32
-
Then you should double check, because you have to get an OpenSSL build that uses the same compiler.
-
@SGaist My compiler is Desktop(x86-windows-msvc2019_pe_32bit_Debug).
-
In the Run part of the Project panel, did you also modify the PATH environment variable so the OpenSSL dlls can be found ?
Do not do that system wide.
-
@SGaist To be honest, I don't really understand what to do.
Here's a screenshot of the Project panel. Could you please navigate me what to do?
-
Unfold the Run Environment part, you'll have there the variables you can modify.
-
@SGaist Here it is. Now what I need to modify?
-
I meant click on the "Details" arrow under Run Environment.
-
@SGaist Oh, my excuses.
Here it is
-
@SGaist So, now what I need to modify?
-
@Sahak After you selected the
Path
variable, you can usePrepend Path
to add the path to the libraries (DLLs) to yourPath
variable. Then at runtime, this directory searched when the DLLs are loaded.Regards
-
@aha_1980
I "Append the path" in PATH, as you see on the screenshot.Then the compiler doesn't work and forcefully finishes the program
-
You application seems to crash, what do you get if running it through the debugger ?