Cannot get SSL to work with Qt6.5.2 on Linux
-
wrote on 4 Sept 2023, 17:12 last edited by
Hi, I am using Qt6.5.2 to send a HTTPS request. I am getting an error that SSL versions are incompatible:
- Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)
However I have in stalled openssl 3:
> openssl version -a OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022) built on: Wed May 24 17:12:55 2023 UTC platform: debian-amd64 options: bn(64,64) compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-Z1YLmC/openssl-3.0.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 OPENSSLDIR: "/usr/lib/ssl" ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-3" MODULESDIR: "/usr/lib/x86_64-linux-gnu/ossl-modules" Seeding source: os-specific CPUINFO: OPENSSL_ia32cap=0x7ffaf3bfffebffff:0x40000000029c67af
I added this debug info to see what version Qt thinks it is dealing with:
qDebug() << "Device supports OpenSSL: " << QSslSocket::supportsSsl(); qDebug() << "OpenSSL lib:" << QSslSocket::sslLibraryVersionString(); qDebug() << "OpenSSL lib build:" << QSslSocket::sslLibraryBuildVersionString();
I get the following output:
18:52:04.135 debug Xrpc::Client::Client'12 Device supports OpenSSL: false 18:52:04.135 debug Xrpc::Client::Client'13 OpenSSL lib: "" 18:52:04.135 debug Xrpc::Client::Client'14 OpenSSL lib build: ""
It does not find any SSL versions, not in the build, not on the system. Yet the error says it is built with version 3.x
I am using open source version of Qt 6.5.2 installed with the maintenance tool.
Can someone help me on how to fix this?
-
Lifetime Qt Championwrote on 4 Sept 2023, 17:18 last edited by SGaist 9 Apr 2023, 17:19
Hi,
Can you start your application with strace ? This should show where the OpenSSL library is searched for.
-
Hi,
Can you start your application with strace ? This should show where the OpenSSL library is searched for.
wrote on 4 Sept 2023, 17:32 last edited by@SGaist Thanks for your quick reaction!
I ran it with strace and grepped its output for ssl. There are some errors in there:
readlink("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", 0x7ffd79596810, 1023) = -1 EINVAL (Invalid argument) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", O_RDONLY|O_CLOEXEC) = 36 readlink("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/qopensslbackend.debug", 0x7ffd79596810, 1023) = -1 EINVAL (Invalid argument) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so.avx2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) access("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so.avx2", F_OK) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", O_RDONLY|O_CLOEXEC) = 35 openat(AT_FDCWD, "/usr/local/ssl/lib/libcrypto.so", O_RDONLY|O_CLOEXEC) = 35 openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/lib/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/usr/local/ssl/lib/libssl.so", O_RDONLY|O_CLOEXEC) = 35
Not sure if the "Invalid argument" errors are fatal. The "no such file" errors seems to suggest I am missing some libs from the Qt installation.
I also grepped for "tls". That gives a lot of output. Here are the first few lines:
readlink("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", 0x7ffd79596810, 1023) = -1 EINVAL (Invalid argument) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", O_RDONLY|O_CLOEXEC) = 36 readlink("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/qopensslbackend.debug", 0x7ffd79596810, 1023) = -1 EINVAL (Invalid argument) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so.avx2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) access("/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so.avx2", F_OK) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/plugins/tls/libqopensslbackend.so", O_RDONLY|O_CLOEXEC) = 35 openat(AT_FDCWD, "/usr/local/ssl/lib/libcrypto.so", O_RDONLY|O_CLOEXEC) = 35 openat(AT_FDCWD, "/home/michel/Qt/6.5.2/gcc_64/lib/libssl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/usr/local/ssl/lib/libssl.so", O_RDONLY|O_CLOEXEC) = 35
Similar errors pointing at missing libs.
-
Something is looking strange, why do you have OpenSSL in
/usr/local/ssl
? That's not a standard place for a distribution provided library. -
Something is looking strange, why do you have OpenSSL in
/usr/local/ssl
? That's not a standard place for a distribution provided library.wrote on 5 Sept 2023, 10:14 last edited by@SGaist You are right!
Several months ago I had an issue with openssl 3. To work around it I installed openssl 1 in /usr/local. I just removed it and now it all works!
Thanks for your help! -
@SGaist You are right!
Several months ago I had an issue with openssl 3. To work around it I installed openssl 1 in /usr/local. I just removed it and now it all works!
Thanks for your help!Great !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three doted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)
-
1/6