![](/img/trans.png)
[英]Qt SSl Error (QSslSocket: cannot resolve TLSv1_1_client_method)
[英]QSslSocket cannot resolve and Permission Denied error
錯誤消息如下:
qt.network.ssl:QSslSocket:無法解析TLSv1_1_client_method
qt.network.ssl:QSslSocket:無法解析TLSv1_2_client_method
qt.network.ssl:QSslSocket:無法解析TLSv1_1_server_method
qt.network.ssl:QSslSocket:無法解析TLSv1_2_server_method
qt.network.ssl:QSslSocket:無法解析SSL_select_next_proto
qt.network.ssl:QSslSocket:無法解析SSL_CTX_set_next_proto_select_cb
qt.network.ssl:QSslSocket:無法解析SSL_get0_next_proto_negotiated
qt.network.ssl:QSslSocket:無法解析SSL_set_alpn_protos
qt.network.ssl:QSslSocket:無法解析SSL_CTX_set_alpn_select_cb
qt.network.ssl:QSslSocket:無法解析SSL_get0_alpn_selected
我運行Windows 7計算機,在D:驅動器上安裝了openssl 1.1.0。 我正在使用Qt5.9.0
我的簡歷
QT += core network
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \
server.cpp \
commands.cpp \
packet.cpp
HEADERS += \
server.h \
commands.h \
packet.h
INCLUDEPATH += D:\OpenSSL-Win32\include\openssl
INCLUDEPATH += D:\OpenSSL-Win32\bin
LIBS += -L D:\OpenSSL-Win32\lib -llibcrypto
LIBS += -L D:\OpenSSL-Win32\lib -llibssl
這是觸發錯誤的代碼:
QString Commands::getPublicIp()
{
QString temp;
QNetworkAccessManager networkManager;
QUrl url("http://api.ipify.org");
QString query = "format=json";
url.setQuery(query);
QNetworkReply* reply = networkManager.get(QNetworkRequest(url));
QObject::connect(
reply
, &QNetworkReply::finished
, [&](){
if(reply->error() != QNetworkReply::NoError) {
return QString();
} else {
QJsonObject jsonObject= QJsonDocument::fromJson(reply->readAll()).object();
QHostAddress ip(jsonObject["ip"].toString());
temp = QString("002 " + ip.toString());
}
reply->deleteLater();
}
);
return temp;
}
我一直收到qt.network.ssl錯誤,並且在鏈接openssl之后,我一直收到編譯錯誤:
:-1:錯誤:找不到D:\\ OpenSSL-Win32 \\ lib:權限被拒絕
:-1:錯誤:找不到-llibssl
collect2.exe:-1:錯誤:錯誤:ld返回了1個退出狀態
即使我當前不使用OpenSSL,我也願意稍后使用它。
僅Qt 5.10支持OpenSSL 1.1.0。 請使用OpenSSL 1.0.2l,您可以使用與npcglib中的編譯器匹配的預構建軟件包。
您的LIBS +=
包含是正確的,但似乎您的計算沒有權限或未找到庫。 無法確定為什么會發生此錯誤。 驗證文件夾中是否存在庫,並且您的用戶具有訪問權限。
QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request)
是一個異步調用。 您的函數QString Commands::getPublicIp()
可能會在請求完成之前返回一個空的QString。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.