OpenSSL 1.1.1 and Qt 5.12.4

30/07/2019 - 15:27
No votes yet

New in Qt 5.12.4 was the switch from OpenSSL 1.0 series to OpenSSL 1.1.1 series in their binary builds. That is all very awesome and secure and all that but when you are for reason or another stuck on a distribution that only supplies OpenSSL 1.0 you are in a bit of a trouble when your perfectly fine Qt apps start to produce this

qt.network.ssl: QSslSocket: cannot resolve OPENSSL_init_ssl
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_init_crypto
qt.network.ssl: QSslSocket: cannot resolve ASN1_STRING_get0_data
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_reset
qt.network.ssl: QSslSocket: cannot resolve RSA_bits
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_new_null
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_push
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_free
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_num
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_pop_free
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_value
qt.network.ssl: QSslSocket: cannot resolve DH_get0_pqg
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_options
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_ciphersuites
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot resolve SSL_get_client_random
qt.network.ssl: QSslSocket: cannot resolve SSL_SESSION_get_master_key
qt.network.ssl: QSslSocket: cannot resolve SSL_session_reused
qt.network.ssl: QSslSocket: cannot resolve SSL_set_options
qt.network.ssl: QSslSocket: cannot resolve TLS_method
qt.network.ssl: QSslSocket: cannot resolve TLS_client_method
qt.network.ssl: QSslSocket: cannot resolve TLS_server_method
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_CTX_get0_chain
qt.network.ssl: QSslSocket: cannot resolve X509_getm_notBefore
qt.network.ssl: QSslSocket: cannot resolve X509_getm_notAfter
qt.network.ssl: QSslSocket: cannot resolve X509_get_version
qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version_num
qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version
qt.network.ssl: Incompatible version of OpenSSL

output and not https connection work anymore. For example on Ubunut 16.04 or derivatives like Linux Mint 18.3.

So what we need to do is build OpenSSL 1.1.1 libraries ourselves to make Qt 5.12.4 happy. Fortunately that is quite easy, just follow these instructions.

Download OpenSSL 1.1.1

Next, download OpenSSL source archive from the 1.1.1 series, latest at time of writing was 1.1.1k (Always use the latest version and remember to update from time to time):

wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz

Extract the source archive:

tar xf openssl-1.1.1k.tar.gz

And go into the source directory:

cd openssl-1.1.1k

Configure and build (assuming x86_64, adjust if you are using something else)

./Configure shared --prefix=/usr --openssldir=/usr/lib/ssl --libdir=lib no-idea no-mdc2 no-rc5 no-zlib no-ssl3 enable-ec_nistp_64_gcc_128 linux-x86_64

Build it:

make -j4

Install the libssl.so and libcrypto.so libraries

If all goes well, copy the 1.1 libraries into /usr/local/lib (or whereever you prefer to have them)

sudo cp libssl.so.1.1 libcrypto.so.1.1 /usr/local/lib/

And update the library cache with ldconfig:

sudo ldconfig

And thats it, you Qt 5.12.4 should now work openssl and with https connections again.

Changelog: 
30/07/2019 - 15:12
Keywords: 
OpenSSL, Qt