Using OpenSSL 3 https connection
-
Hello Folks!
I need to access a https connection in Qt 5 with a windows and a linux build.
This is the code I am trying tu use:
QNetworkAccessManager nam; QSslConfiguration config( QSslConfiguration::defaultConfiguration() ); QNetworkRequest req(QUrl("https://myurl.file")); req.setSslConfiguration( config ); QNetworkReply* reply = nam.get(req); QEventLoop loop; QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); bool isConnected = reply->bytesAvailable(); // false
What do i need to connect via OpenSSL3 (Windows and Linux Client)
best regards, kevin
-
Hi,
Two conditions:
- have a build of Qt which supports OpenSSL 3
- have the OpenSSL 3 libraries in a suitable place where Qt can load them.
-
On Windows:
- With the Qt MaintenanceTool, I installed "OpenSSL 3.0.15 Toolkit" 64 bit Binaries.
- From X:\Qt3D\Tools\OpenSSLv3\Win_x64\bin, I copied "libcrypto-3-x64.dll" and "libssl-3-x64.dll" to my build directory
- In my .pro-File, I added
- LIBS += X:\Qt3D\Tools\OpenSSLv3\Win_x64\lib\libcrypto.lib
- LIBS += X:\Qt3D\Tools\OpenSSLv3\Win_x64\lib\libssl.lib
- INCLUDEPATH += X:\Qt3D\Tools\OpenSSLv3\Win_x64\include\openssl
Also, i added the path to the .dlls to the Windows-PATH variable.
According to "https://doc.qt.io/qt-5/windows-requirements.html", i added- libcrypto-3-x64.dll and
- libssl-3-x64.dll
to the X:\Windows\system32 folder.
The runtime states:
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
sslibbuild: "OpenSSL 1.1.1g 21 Apr 2020"
ssllibversionstring: ""
supportsSsl: falseAnd connection still fails.
What am I missing?
best regards, kevin
-
@kevin_d said in Using OpenSSL 3 https connection:
I need to access a https connection in Qt 5
@SGaist said in Using OpenSSL 3 https connection:
have a build of Qt which supports OpenSSL 3
Although this is not my area, start by checking exactly which version of Qt 5 you have? Read through e.g. https://forum.qt.io/topic/136960/does-qt-5-15-support-openssl-3-x. It appears to me you need Qt 5.15.13 onward. I am unclear whether it requires you to build the Qt 5.x with this support yourself. Google
qt 5 ssl 3
for further reading, e.g. maybe https://gist.github.com/seyedmmousavi/b1f6681eb37f3edbe3dcabb6e89c5d43.Assuming you do need SSL 3, I don't know whether you might be better considering upgrading your own to Qt 6.
-
@piervalli Qt 5.15.2 does support OpenSSL 1.1 it's 3.0 that's not supported.
-
Indeed. As per the post I drew attention to previously, apparently for Qt5 with SSL/OpenSSL 3 you would need 5.15.3, and OP only has 5.15.2 :(
I am still not sure whether the 5.15.3 has to be compiled a certain way (option) to make it do SSL at all or SSL 3 at least. If you get one pre-compiled by someone else you would need to check this.