Ubuntu上的Qt和OpenSSL不兼容版本

时间:2018-09-06 19:01:33

标签: qt ubuntu openssl

我在尝试使QNetwork类与Ubuntu 18.04上的Qt5.11.1配合使用时遇到问题

我的系统上安装了openssl 1.1.0g和libssl-dev。

Qt使用的openssl版本是1.0.2k。我已经与QSslSocket::sslLibraryBuildVersionString()进行了核对。加QSslSocket::supportsSsl()返回false

我正在努力解决这个问题,但是我总是遇到这些错误:

qt.network.ssl: QSslSocket: cannot resolve CRYPTO_num_locks
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_set_id_callback
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_set_locking_callback
qt.network.ssl: QSslSocket: cannot resolve ERR_free_strings
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_cleanup
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_init
qt.network.ssl: QSslSocket: cannot resolve sk_new_null
qt.network.ssl: QSslSocket: cannot resolve sk_push
qt.network.ssl: QSslSocket: cannot resolve sk_free
qt.network.ssl: QSslSocket: cannot resolve sk_num
qt.network.ssl: QSslSocket: cannot resolve sk_pop_free
qt.network.ssl: QSslSocket: cannot resolve sk_value
qt.network.ssl: QSslSocket: cannot resolve SSL_library_init
qt.network.ssl: QSslSocket: cannot resolve SSL_load_error_strings
qt.network.ssl: QSslSocket: cannot resolve SSL_get_ex_new_index
qt.network.ssl: QSslSocket: cannot resolve SSLv3_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv23_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv3_server_method
qt.network.ssl: QSslSocket: cannot resolve SSLv23_server_method
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_CTX_get_chain
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot resolve SSLeay
qt.network.ssl: Incompatible version of OpenSSL

我已经检查了多个与此有关的问题和论坛,但似乎对我没有任何帮助。有人知道吗?

4 个答案:

答案 0 :(得分:3)

我终于设法使它起作用。

我已经从源代码安装了openssl 1.0.2k。我已经下载了需要的版本here,并按照this page上的教程进行操作。

这样做之后,我仍然遇到一些错误,但对于不兼容的版本却没有。要修复我已经安装的libssl1.0-dev,一切都很好(谢谢this guy)。

我希望这会对某人有所帮助。

答案 1 :(得分:2)

我已将<?php foreach($tickerDisplays as $key => $ticker):?> <form id="Items" method="post"> <label id="ItemLabel">Item 1: </label> <input type="text" name="Items[]"><br/> <!--form starts with one input--> <button type="button" class="moreItems_add">+</button> <!--button dynamically adds input, up to 10 per form--> <input type="hidden" name="tickerID" id="tickerID" class="tickerIdClass" value="<?php echo $ticker['ticker'] ?>"><!--hidden input used for tickerID--> <input type="submit" name="saveTickerItems" value="Save Ticker Items"> <!--submit button--> </form> <?php endforeach;?> <!-- This is the functionality for each form to click the '+' button and create new inputs --> <script type="text/javascript"> $("button.moreItems_add").on("click", function(e) { var tickerID = $(this).closest('form').find('.tickerIdClass').val(); //get value of hidden input for form var numItems = $("input[type='text']", $(this).closest("form")).length; if (numItems < 10) { var html = '<label class="ItemLabel">Item ' + (numItems + 1) + ': </label>'; html += '<input type="text" name="Items[]"/><br/>'; $(this).before(html); console.log(tickerID); } }); </script> <!-- This is the ajax call to send all filled out and created inputs from form along with the hidden input --> <script type="text/javascript"> $("#Items").submit(function(e) { e.preventDefault(); var data = $("#Items").serializeArray(); console.log(data); $.ajax({ type: "POST", url: "addticker.php", data: $("#Items").serializeArray(), // serializes the form's elements. success: function(data) { alert(data); // show response from the php script. } }); }); </script> libcrypto.so(v1.0.2)复制到当前的编译器lib目录(libssl.so)中。 在我的情况下,我在<QTDIR>/5.11.1/gcc_64/lib中使用了theese 2个库:/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0,并进行了复制和重命名。 它对我有用。

答案 2 :(得分:0)

我通过以下方式解决了创建opensl 1.1.0链接的问题:

  1. 在/ opt / f5 / vpn / lib中删除libcrypto.so.1.0.0和libssl.so.1.0.0;
  2. 创建链接:

    sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /opt/f5/vpn/lib/libcrypto.so.1.0.0 
    
    sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /opt/f5/vpn/lib/libssl.so.1.0.0
    

答案 3 :(得分:0)

我在Ubuntu 16.04上使用Qt 5.13.1遇到了这个问题。

在我的Qt环境中,QSslSocket::sslLibraryBuildVersionString()QSslSocket::supportsSsl()的值为"OpenSSL 1.1.1b 26 Feb 2019"false

每次QNetworkAccessManager访问https地址时都会生成此输出:

qt.network.ssl: QSslSocket: cannot resolve OPENSSL_init_ssl
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_init_crypto
qt.network.ssl: QSslSocket: cannot resolve ASN1_STRING_get0_data
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_reset
qt.network.ssl: QSslSocket: cannot resolve RSA_bits
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_new_null
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_push
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_free
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_num
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_pop_free
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_sk_value
qt.network.ssl: QSslSocket: cannot resolve DH_get0_pqg
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_options
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_ciphersuites
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot resolve SSL_get_client_random
qt.network.ssl: QSslSocket: cannot resolve SSL_SESSION_get_master_key
qt.network.ssl: QSslSocket: cannot resolve SSL_session_reused
qt.network.ssl: QSslSocket: cannot resolve SSL_set_options
qt.network.ssl: QSslSocket: cannot resolve TLS_method
qt.network.ssl: QSslSocket: cannot resolve TLS_client_method
qt.network.ssl: QSslSocket: cannot resolve TLS_server_method
qt.network.ssl: QSslSocket: cannot resolve X509_up_ref
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_CTX_get0_chain
qt.network.ssl: QSslSocket: cannot resolve X509_getm_notBefore
qt.network.ssl: QSslSocket: cannot resolve X509_getm_notAfter
qt.network.ssl: QSslSocket: cannot resolve X509_get_version
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_set_ex_data
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_get_ex_data
qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version_num
qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version
qt.network.ssl: Incompatible version of OpenSSL
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

以上所有解决方案都不适合我。我在Ubuntu上安装了Homebrew软件包管理器,然后像这样安装了openssl@1.1

$ brew install openssl@1.1

然后我将这些行添加到我的项目文件中:

LIBS += -L/home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1c/lib -lssl -lcrypto
INCLUDEPATH += /home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1c/include

QSslSocket::sslLibraryBuildVersionString()的值仍然是旧值"OpenSSL 1.1.1b 26 Feb 2019",但是QSslSocket::supportsSsl()的值变成了true,这解决了我的问题。