让openSSL在Mac上使用Qt

时间:2016-01-06 19:02:53

标签: macos qt https openssl

我正在对谷歌地图进行一些api调用,其中一些需要加密,所以我使用https。每当我使用https发出请求时,我都会收到错误:

qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiated

我在使用http时也会遇到这些错误,但我仍然会收到我想要的数据,而使用https我不会。 我看到这显然是因为我没有安装openSSL,所以我检查了我的版本0.9.8,所以我安装了一个较新的版本(1.0.2)(请注意我在Mac上)但仍然有同样的问题。我已经看到了很多类似的问题,但要么没有解决方案,要么就是有一个它不适合我,或者我不明白实际做什么。

我运行了以下代码:

     qDebug() << "Support SSL:  " << QSslSocket::supportsSsl()
                << "\nLib Version Number: " << QSslSocket::sslLibraryVersionNumber()
                << "\nLib Version String: " << QSslSocket::sslLibraryVersionString()
                << "\nLib Build Version Number: " << QSslSocket::sslLibraryBuildVersionNumber()
                << "\nLib Build Version String: " << QSslSocket::sslLibraryBuildVersionString();

并收到输出:

qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
Support SSL:   true 
Lib Version Number:  9470431 
Lib Version String:  "OpenSSL 0.9.8zg 14 July 2015" 
Lib Build Version Number:  268439727 
Lib Build Version String:  "OpenSSL 1.0.1j 15 Oct 2014"

列出的版本不是指我最近安装的版本,所以问题可能是它没有使用新版本?

如果有人知道如何解决此问题,那么我可以毫无错误地使用https,请提供具体说明,因为我没有经验。

由于

1 个答案:

答案 0 :(得分:1)

SSL警告不是致命的;安全连接应该继续工作。根据{{​​3}},您可以通过设置以下环境变量来抑制这些消息:

QT_LOGGING_RULES=qt.network.ssl.warning=false

此外,我非常确定这些警告消息(或非常类似的消息)出现在OS X以外的平台上。