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

前端 未结 6 1715
野趣味
野趣味 2021-01-01 09:46

I have an app that uses the QWebSocket class but not SSL. It works fine when I execute a version compiled with Qt 5.3 but a Qt 5.7 executable freezes on the following warnin

6条回答
  •  情话喂你
    2021-01-01 10:23

    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: "<

    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)

提交回复
热议问题