qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
-
Qt 6.6.1
Ubuntu 22.04My app needs to send email and that requires TLS to connect.
I had the App working last July. Went to add a feature, updated Qt Creator before updating my App. In July timeframe OpenSSL 1.1 was the only thing supported. Now it looks like OpenSSL 3 is supported. I made sure both were enabled in Qt management. Everything compiles fine. The App runs on the development system but when I deploy it using qt-deployer and put it on another machine the App runs but TLS fails.
Everything (that I have found) on Google is old and talks about OpenSSL 5 not being supported, use OpenSSL 1.1. Both are installed but both give the TLS error. I also installed each separately and removed the other but no success.
If I do ldd using the run script so the environment is setup correctly, I do not see any reference to any ssl libraries and no missing libraries. I look in :~/Qt/6.6.1/gcc_64/lib and there is no libssl libraries so it is using the system libraries for SSL. Both the development system and the deployment system are on Ubuntu 22.04 and fully up to date.
In the run script I added the system libraries path just to make sure:
export LD_LIBRARY_PATH="$BASEDIR/lib":/lib/x86_64-linux-gnuIn mainwindow.h I have included:
#include <QtNetwork/QAbstractSocket>
#include <QtNetwork/QSslSocket>
Is there something else required for Qt 6.6?Any ideas?
-
Hi and welcome to devnet,
The Qt binaries from the online installer do not link directly to OpenSSL, they dlopen its libraries.
-
@TLaren said in qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed:
If I do ldd using the run script so the environment is setup correctly, I do not see any reference to any ssl libraries
@SGaist responded to this. Since Qt does not link against the SSL libraries (it loads them instead at runtime using dlopen) ldd will not show them.
-
TLS requires the TLS plugin.
I guess qt-deployer does not do a very good job including what is needed.
I copied over the plugins/TLS directory over to the deployment machine and it's fixed.TLS/ libqcertonlybackend.so libqopensslbackend.so libqcertonlybackend.debug libqopensslbackend.debug
I want to thank everyone that looked and I am posting the fix so the next time I forget what I am doing I can search here to fix my problem also maybe it will help someone else.