为什么在Debian Stretch上QsslSocket与Qt 5.3一起使用而不与Qt 5.7一起使用? [英] Why is QsslSocket working with Qt 5.3 but not Qt 5.7 on Debian Stretch?
问题描述
我有一个使用 QWebSocket类的应用>但不是SSL。当我执行使用Qt 5.3编译的版本但Qt 5.7可执行文件因以下警告而冻结时,它工作正常:
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 warnings:
QSslSocket: cannot resolve CRYPTO_num_locks
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve ERR_free_strings
QSslSocket: cannot resolve EVP_CIPHER_CTX_cleanup
QSslSocket: cannot resolve EVP_CIPHER_CTX_init
QSslSocket: cannot resolve sk_new_null
QSslSocket: cannot resolve sk_push
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num
QSslSocket: cannot resolve sk_pop_free
QSslSocket: cannot resolve sk_value
QSslSocket: cannot resolve SSL_library_init
QSslSocket: cannot resolve SSL_load_error_strings
QSslSocket: cannot resolve SSL_get_ex_new_index
QSslSocket: cannot resolve SSLv2_client_method
QSslSocket: cannot resolve SSLv3_client_method
QSslSocket: cannot resolve SSLv23_client_method
QSslSocket: cannot resolve SSLv2_server_method
QSslSocket: cannot resolve SSLv3_server_method
QSslSocket: cannot resolve SSLv23_server_method
QSslSocket: cannot resolve X509_STORE_CTX_get_chain
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
QSslSocket: cannot resolve SSLeay
QSslSocket: cannot resolve SSLeay_version
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function sk_num
我没有在5.3版本中看到这些警告(工作正常),这表明我不应该请忽略此问题,按照此问题的要求。另外, QT + = network
是已经在我的src.pro 中。
I am not seeing these warnings in the 5.3 version (that works properly), which suggests that I should not ignore them, as asked in this question. Also, QT += network
is already in my src.pro.
我被认为是 Debian从openssl软件包中删除了这些符号。谁能告诉我这是怎么回事,我该如何解决?
I was led to believe that Debian dropped these symbols from the openssl package. Could anyone tell me what's going on here and how I could fix this?
我在Debian Stretch上运行
I'm running on Debian stretch
$ uname -r
4.8.0-2-amd64
我已经安装了openssl和libssl-dev
I have openssl and libssl-dev installed
openssl is already the newest version (1.1.0c-2).
libssl-dev is already the newest version (1.1.0c-2).
我已经尝试使用Qt 5.3和5.7来运行它
I've tried running this with Qt 5.3 and 5.7
$ qmake -v
QMake version 3.0
Using Qt version 5.7.1 in /usr/lib/x86_64-linux-gnu
推荐答案
TL; DR
Debian Stretch随OpenSSL 1.1一起提供; Qt使用OpenSSL 1.0;给Qt所需的东西:
Debian Stretch is shipped with OpenSSL 1.1; Qt uses OpenSSL 1.0; give Qt what it needs:
apt install libssl1.0-dev
详细答案
从关于OpenSSL和Qt的答案中,我找到了一个提示并显示用于以下操作的编译时和运行时的SSL库版本:
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: "<<QSslSocket::sslLibraryBuildVersionString();
qDebug()<<"SSL version use for run-time: "<<QSslSocket::sslLibraryVersionNumber();
qDebug()<<QCoreApplication::libraryPaths();
它会显示:
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")
但是Debian Stretch随OpenSSL 1.1一起提供。不出所料,有关此问题的所有Web线程都是对的:这是OpenSSL库版本兼容性问题。
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.
我易于安装libssl1.0-dev,问题解决了。我仍然有2条关于SSLv3的SSL警告,但这至少只是警告(我在网上阅读了有关此内容的内容,无法再次找到它)。
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")
摘要
在Qt支持OpenSSL 1.1之前,您可以:
Until Qt supports OpenSSL 1.1, you can either:
- 安装OpenSSL 1.0(可能在Debian中)
- 编译OpenSSL 1.0并安装它(我没有测试,但应该可以作为1工作)。
- Ship将OpenSSL 1.0与您的Qt应用程序结合使用(我没有测试过,但应该可以作为1使用)。
- 使用 -openssl-linked选项重新编译Qt(根据这个答案,我没有测试,也不想这么做)
- Install OpenSSL 1.0 (possible in Debian)
- Compile OpenSSL 1.0 and install it (I did not test, but should work as 1.)
- Ship OpenSSL 1.0 with your Qt application (I did not test, but should work as 1.)
- Recompile Qt with "-openssl-linked" option (according to this answer, I did not test and I do not want to)
这篇关于为什么在Debian Stretch上QsslSocket与Qt 5.3一起使用而不与Qt 5.7一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!