Include OpenSSL
-
Hello,
I need to use https with QNetworkManager. For that, I need OpenSSL. However, I was not able to include it in the project.
As Qt Maintanance Tool allows installation of OpenSSL, I thought, it would be the best way to go. Though I could make SSL work only by downloading OpenSSL precompiled separately and copy the dlls (ssleay32 and libeay32) directly next to the exe.
That worked until I wanted to deploy the program and test it in clean VM, where it can not access SSL enabled websites.How should I include the "bundled" OpenSSL to my project?
I tried to add following two lines to the .pro file:
LIBS += "C:/Qt/Tools/OpenSSL/Win_x64/lib/libssl.lib" LIBS += "C:/Qt/Tools/OpenSSL/Win_x64/lib/libcrypto.lib"
Then I am able to include OpenSSL libraries to cpp but QNetworkManager still says
QSslSocket::connectToHostEncrypted: TLS initialization failed
.Just to clarify, I use 64-bit Windows.
Thank you for any help.
-
Hi,
You need to make them available to your application at run time. Go to the Run part of the Project panel and modify there the Path environnement variable and the folder where the OpenSSL dlls can be found.
-
You can do that with windeployqt. You likely will have to add the OpenSSL dlls by hand. Using encryption in software hits certain restrictions in some countries so it can't be just added automatically unconditionally.
-
Thank you for your help.
Exactly as you said, I deploy it using windeployqt, copy the necessary dlls and it runs. The only thing I had to do to make it work was to install MSVC++ 2010 Runtime, which took a while to spot (there is no popup or anything to it, so I thought, it did not see the dlls).Now, to get rid of the MSVC, I will probably have to compile OpenSSL on my own, which I currently struggle with a bit but that's a different topic.
-
Dependency Walker is another good tool to have to check what dependencies you may have missed.
-
Dependency Walker is another good tool to have to check what dependencies you may have missed.