13

I am running Qt 5.7.1 (MSVC 2015, 32 bit) with Qt Creator 4.2.0. I have a problem with QSslSocket. I am getting the following errors:

qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error

I have gone to the following location openssl github and downloaded the zip file. I have moved the "libeay32.dll" and "ssleay32.dll" files to my release directory, and I am still getting these errors. Is there anyone who has gotten the QSslSocket working that can give me steps to get the socket working or has any suggestions?

Rama
  • 3,222
  • 2
  • 11
  • 26
KirstenS
  • 145
  • 1
  • 1
  • 7
  • drescherjm, thanks for the quick response. Is that something i specify in the .pro file? And where do I find the .lib? I have OpenSSL-Win32 on my local disk (C:), but there are no .lib files. – KirstenS Jan 25 '17 at 17:53
  • 3
    Possible duplicate of [Unresolved Functions While Working With QSslSocket](http://stackoverflow.com/questions/10846536/unresolved-functions-while-working-with-qsslsocket) – drescherjm Jan 25 '17 at 17:55
  • Sorry, I thought that was a linker error not a runtime error. I believe this message this is due to the plugin usage in Qt. – drescherjm Jan 25 '17 at 17:57
  • Ok, thanks for the help. Do you have any suggestions for how to fix runtime errors? I have looked an the previous topic "Unresolved Functions..." but I believe I tried the solution they suggested (copying the dlls to the release folder) and it didn't work. Any suggestions? Thanks! – KirstenS Jan 25 '17 at 17:59
  • Did you add `QT += network` to your pro? – drescherjm Jan 25 '17 at 18:05
  • yes, I do have that in my .pro file – KirstenS Jan 25 '17 at 18:56
  • It may sound basic but, are you executing the release configuration? I mean, if you are executing the debug configuration then you should copy the DLLs to the debug directory too. On the other hand, are you using the same version of OpenSSL libraries for which your Qt distribution was compiled? – cbuchart Feb 17 '17 at 15:14
  • did you manage to solve it? i have same problem – mohammad alabid Jun 04 '17 at 11:19

5 Answers5

11

I ended up here via Googling around. In my case, I was getting this error on random machines because they were missing the correct versions of libeay32.dll and ssleay32.dll. It's "random" because some computers have these loaded in PATH from other software and some do not.

I fixed this for Qt Creator by adding the DLLs to the bin folder of my Qt install, and I fixed this on distributions by including the aforementioned DLLs in my distribution.

The DLLs should be the same or similar to the version of OpenSSL that Qt was compiled with in the first place. If you didn't compile it yourself, starting in Qt 5.4 you can query this with QSslSocket::sslLibraryBuildVersionString(). (Credit: https://stackoverflow.com/a/42297296/1666676)

Don't forget that your 64-bit apps should have a 64-bit version of the DLLs, and 32-bit apps should have 32-bit DLLs so you don't have the same problem as this guy.


Additional notes:

  • Starting in Qt 5.2 you must use version 1.0.0 or newer. 0.9.8 doesn't work any more. (Source: http://doc.qt.io/qt-5/ssl.html)
  • For my standard MSVC2017x64 distribution of Qt 5.10.1 sslLibraryBuildVersionString() returned "OpenSSL 1.0.2o". I use 1.0.2p for my distributions.
  • The OpenSSL DLLs changed names to libcrypto-1_1*.dll and libssl-1_1*.dll starting in OpenSSL 1.1.0. Standard Qt distributions don't yet use those as of Sept. 2018.
  • OpenSSL GitHub downloads are here: https://github.com/openssl/openssl/tags

Hope this helps the next person. Sorry for resurrecting an old post.

Phlucious
  • 3,704
  • 28
  • 61
  • "Of course, you should ensure that you're packaging the same DLLs as the version of OpenSSL that Qt was compiled with in the first place." How do I do this? – sitting-duck Sep 19 '18 at 18:50
  • 1
    Good question! I found a hint to that [here](https://stackoverflow.com/a/39497754/1666676) and [here](https://stackoverflow.com/a/42297296/1666676). In short, use `QSslSocket::sslLibraryBuildVersionString()`. I'll add that to my answer. – Phlucious Sep 19 '18 at 18:59
7

Copy these two file to path: 'C:\Qt\Tools(msvc/mingw){version}\bin'

C:\Qt\Tools\(msvc|mingw)\opt\bin\libeay32.dll
C:\Qt\Tools\(msvc|mingw)\opt\bin\ssleay32.dll
Hamed Nikzad
  • 618
  • 8
  • 14
3

You need to Add support to OppenSSL manually, since android dropped the support of it, and i am using QT 5.9 and its not make it for you so its your mission to create openSSL lib

You can download it directly here https://wiki.openssl.org/index.php/Binaries

or here https://indy.fulgan.com/SSL/

and then copy these filed and include them to your project

libcrypto.so
libssl.so

That should work correctly

Or you can generate your libcrypto.so and libssl.so using this script , just follow it step by step https://github.com/ekke/android-openssl-qt

mohammad alabid
  • 444
  • 7
  • 21
  • https network requests work fine in Qt Android 4.4 app. @mohammad alabid , do you know when Android dropped support? Android >= 6.0 ? On Android 7.0 the same Qt app fails "qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_ctrl" even though I can see *both* ib.libcrypto.so and libssl.so in the Android /system/lib/ directory? – Ed of the Mountain Jul 18 '18 at 15:05
  • Yes support for SSlSockets dropped in Android, Did you tried to build .so files? you can try these files https://www.dropbox.com/s/w6cm09niyj185fb/openSSL.zip?dl=0 -add those 3 files beside .pro file -and add this line to your .pro file include(android-openssl.pri) – mohammad alabid Jul 19 '18 at 07:32
  • Be sure to use openssl 1.1 as openssl 3 has deprecated these functions :/ – Gearoid Murphy May 03 '23 at 22:35
0

By combining existing answers here and some research I managed to make it work with MSVC2017 x64 compiler:

  1. Download 1.0 version (Win64 OpenSSL v1.0.2r Light) from here: https://slproweb.com/products/Win32OpenSSL.html
  2. When installing, choose to copy DLLs to OpenSSL bin directory.
  3. And then copy libeay32.dll and ssleay32.dll from OpenSSL bin folder to: {Your_Qt_Folder}/{Qt_version}/msvc2017_64/bin
max paint
  • 49
  • 6
0

I solved this problem.

  1. Download and install v1.0.2s <<--(libeay32.dll, ssleay32.dll) at https://slproweb.com/products/Win32OpenSSL.html

  2. Copy libeay32.dll and ssleay32.dll

  3. Find QtNetwork*.dll in your Qt folder. In my case, path is C:\Qt\Tools\QtCreator\bin.

  4. Paste libeay32.dll and ssleay32.dll in C:\Qt\Tools\QtCreator\bin.

shizhen
  • 12,251
  • 9
  • 52
  • 88