"qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed
-
@keksi-venksi What do you get if you put:
qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();
in your code ?Changing the patch version should not be a problem to load OpenSSL.
Where did you install it ? -
if (QSslSocket::supportsSsl()) {
qDebug() << "SSL is supported.";
} else {
qDebug() << "SSL is not supported.";
qDebug() << "Build Version:" << QSslSocket::sslLibraryBuildVersionString();
qDebug() << "Loaded Version:" << QSslSocket::sslLibraryVersionString();
}
The above code returned a value of
SSL is not supported.
Build Version: "OpenSSL 1.1.1d 10 Sep 2019"
Loaded Version: ""Im using both qt 5.14.2 and qt5.15.2
If i print it in Qt5.14.2 the open ssl version is OpenSSL 1.1.1d
If i print it in Qt5.15.2 the open ssl version is OpenSSL 1.1.1gMy cmd output it
openssl version
OpenSSL 1.1.1q 5 Jul 2022I installed in the C folder "C:\Qt\Qt5.15\5.15.2"
Also I would like to puts some debugging notes
When I use HTTPS:somelink , the reply is TLS initialization failed.
but when I use HTTP:somelink the reply is fine -
That's because the dlls cannot be found at run time hence the empty "Loaded Version".
Go to the Run part of the Project panel and add the path to were the dlls are to the PATH environment variable.
-
@SGaist Which dll's ? openSSL one
I have added this "C:\Qt\Qt5.15\Tools\OpenSSLv3\Win_x64\bin" one into path in both environmental variables and in project run's build environment as well
but dlls name's have an extra point that it has version name in it as libcrypto-3-x64.dll libssl-3-x64.dll
-
This post is deleted!
-
Hi, one other thing you can try is to build and run the "Secure Socket Client Example" in Qt's examples. (it's included both in Qt 5.14 and 5.15.) Make sure you run in it Release mode (not Debug).
If that example works, then maybe you can copy the files from it... -
@keksi-venksi Here it is, since you are using Qt5.15.2, according to the Qt source code (https://code.qt.io/cgit/qt/qtbase.git/tree/src/network/ssl/qsslsocket_openssl_symbols.cpp?h=v5.15.2#n683)
tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX), QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), result);
It will only find v1.1.x of openssl.
-
@hskoglund said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:
Secure Socket Client Example
That example itself not working in my qt 5.14.2
-
@Bonnie said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:
tryToLoadOpenSslWin32Library
how to call this method.
its present in a private class
Please show some code to execute it
-
@keksi-venksi This is Qt's internal source code, you are not supposed to use it. I post it to show that it is hard coded to load openssl v1.1.x only.
-
@keksi-venksi why did you install OpenSSL v3 since you need v1.1 ?
-
@keksi-venksi you need to download openssl 1.1.1 on windows.
When done , copy libssl-1_1-x64.dll and libcrypto-1_1-x64.dll in your qt installation folder, mine is
C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin
After that it will work