Why is QsslSocket working with Qt 5.3 but not Qt 5.7 on Debian Stretch?

TL;DR

Debian Stretch is shipped with OpenSSL 1.1; Qt uses OpenSSL 1.0; give Qt what it needs:

apt install libssl1.0-dev

Detailed answer

From this answer about OpenSSL and Qt, I found a hint and I displayed SSL library version used for compile-time and run-time using:

qDebug()<<"SSL version use for build: "<<QSslSocket::sslLibraryBuildVersionString();
qDebug()<<"SSL version use for run-time: "<<QSslSocket::sslLibraryVersionNumber();
qDebug()<<QCoreApplication::libraryPaths();

And it displays:

SSL version use for build:  "OpenSSL 1.0.1e-fips 11 Feb 2013"
... lot of SSL warnings...
SSL version use for run-time:  0
("/opt/Qt/5.8/gcc_64/plugins", "/home/Project/..../build...Desktop_Qt_5_8_0_GCC_64bit-Release/src/release/build_linux_64")

But Debian Stretch is shipped with OpenSSL 1.1. As expected, all the threads on the Web about this issue are true: this is an OpenSSL library version compatibility issue.

I "apt install libssl1.0-dev" and the problem was solved. I still have 2 SSL warnings about SSLv3, but at least this is only warning (I read something on the Web about it, no way to find it again).

SSL version use for build:  "OpenSSL 1.0.1e-fips 11 Feb 2013"
QSslSocket: cannot resolve SSLv3_client_method
QSslSocket: cannot resolve SSLv3_server_method
SSL version use for run-time:  268443839
("/opt/Qt/5.8/gcc_64/plugins", "/home/Project/..../build...Desktop_Qt_5_8_0_GCC_64bit-Release/src/release/build_linux_64")

Summary

Until Qt supports OpenSSL 1.1, you can either:

  1. Install OpenSSL 1.0 (possible in Debian)
  2. Compile OpenSSL 1.0 and install it (I did not test, but should work as 1.)
  3. Ship OpenSSL 1.0 with your Qt application (I did not test, but should work as 1.)
  4. Recompile Qt with "-openssl-linked" option (according to this answer, I did not test and I do not want to)

I had the same problem on a debian stretch server. I fixed it with the help of 7hibaults comment.

Running the following command fixed the problem for me:

sudo apt-get install libssl1.0-dev

Tags:

Ssl

Qt

Debian