sslqt5qsslsocket

Relation between QT_NO_SSL and QSslSocket::supportsSsl()


There is a define QT_NO_SSL, that is defined if there was no Ssl library found. There also is the method QSslSocket::supportsSsl().

But how are these two related, are they equivalent? Does QT_NO_SSL <=> QSslSocket::supportsSsl() returns false hold or is it possible that QT_NO_SSL is not defined, but QSslSocket::supportsSsl() returns false?


Solution

  • Qt (at least with the OpenSSL backend) can be compiled:

    1. with no SSL support -- QT_NO_SSL defined, SSL classes not even available for compilation;
    2. with SSL support loaded at runtime => OpenSSL headers must be present at compile time, but QtNetwork won't link to libssl/libcrypto/...; instead, it will dlopen those libraries at runtime looking for the functions it needs;
    3. with SSL support linked from QtNetwork.

    The reason for this has to do with the fact that linking QtNetwork to a cryptographic library opens legal problems in terms of redistribution from/to the US. With #3 you must have the SSL libraries around or your application won't start, even if you don't need SSL at all; and Qt installers can't "easily" ship those SSL libraries. So instead Qt gets compiled in configuration #2 and you have the responsability of installing OpenSSL.

    The scenario in which QT_NO_SSL is not defined but QSslSocket::supportsSsl() returns false is #2 (for instance if Qt fails to find or load a suitable SSL library).