简体   繁体   English

QSslSocket无法解决和权限被拒绝错误

[英]QSslSocket cannot resolve and Permission Denied error

The error messages are the following: 错误消息如下:

qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method qt.network.ssl:QSslSocket:无法解析TLSv1_1_client_method

qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method qt.network.ssl:QSslSocket:无法解析TLSv1_2_client_method

qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method qt.network.ssl:QSslSocket:无法解析TLSv1_1_server_method

qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method qt.network.ssl:QSslSocket:无法解析TLSv1_2_server_method

qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto qt.network.ssl:QSslSocket:无法解析SSL_select_next_proto

qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb qt.network.ssl:QSslSocket:无法解析SSL_CTX_set_next_proto_select_cb

qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated qt.network.ssl:QSslSocket:无法解析SSL_get0_next_proto_negotiated

qt.network.ssl: QSslSocket: cannot resolve SSL_set_alpn_protos qt.network.ssl:QSslSocket:无法解析SSL_set_alpn_protos

qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb qt.network.ssl:QSslSocket:无法解析SSL_CTX_set_alpn_select_cb

qt.network.ssl: QSslSocket: cannot resolve SSL_get0_alpn_selected qt.network.ssl:QSslSocket:无法解析SSL_get0_alpn_selected

I run a Windows 7 machine, with openssl 1.1.0 installed on my D: drive. 我运行Windows 7计算机,在D:驱动器上安装了openssl 1.1.0。 And I am using Qt5.9.0 我正在使用Qt5.9.0

My .pro file 我的简历

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

And this is the code that triggers the error: 这是触发错误的代码:

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;

}

I kept getting the qt.network.ssl errors, and after linking openssl I keep getting a compile error: 我一直收到qt.network.ssl错误,并且在链接openssl之后,我一直收到编译错误:

:-1: error: cannot find D:\\OpenSSL-Win32\\lib: Permission denied :-1:错误:找不到D:\\ OpenSSL-Win32 \\ lib:权限被拒绝

:-1: error: cannot find -llibssl :-1:错误:找不到-llibssl

collect2.exe:-1: error: error: ld returned 1 exit status collect2.exe:-1:错误:错误:ld返回了1个退出状态

Even though I am not currently using OpenSSL, I am willing to use it later. 即使我当前不使用OpenSSL,我也愿意稍后使用它。

  1. OpenSSL 1.1.0 is only supported from Qt 5.10. 仅Qt 5.10支持OpenSSL 1.1.0。 Please use OpenSSL 1.0.2l, you can use the pre-built package that matches your compiler from npcglib . 请使用OpenSSL 1.0.2l,您可以使用与npcglib中的编译器匹配的预构建软件包。

  2. Your LIBS += includes are correct, but it appears your compute has no permission or the libraries are not found. 您的LIBS +=包含是正确的,但似乎您的计算没有权限或未找到库。 It cannot be told why this error occurs. 无法确定为什么会发生此错误。 Verify the existence of the libraries in the folder and that your user has access. 验证文件夹中是否存在库,并且您的用户具有访问权限。

  3. QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request) is an asynchron call. QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request)是一个异步调用。 Your function QString Commands::getPublicIp() will probably return an empty QString before the request has finished. 您的函数QString Commands::getPublicIp()可能会在请求完成之前返回一个空的QString。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Qt SSl错误(QSslSocket:无法解析TLSv1_1_client_method) - Qt SSl Error (QSslSocket: cannot resolve TLSv1_1_client_method) 如何处理QSslSocket:无法解决TLSv1_1_client_method错误 - How to handle QSslSocket: cannot resolve TLSv1_1_client_method error qt.network.ssl:QSslSocket:无法解析SSLv2_client_method - qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method 代码::块错误:无法打开输出文件,权限被拒绝 - Code::Blocks Error: Cannot Open Output File, Permission Denied QSslSocket:无法调用未解析的函数 - QSslSocket: cannot call unresolved function 如何解决:- VS Code windows 中的“Permission denied collect2.exe: error: ld returned 1 exit status” - How to resolve:- "Permission denied collect2.exe: error: ld returned 1 exit status" in VS Code windows C ++ Qt应用程序正常运行,但发出警告“ qt.network.ssl:QSslSocket:无法解析SSLv2_server_method” - C++ Qt application working but gives warning “qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method” C ++权限被拒绝错误 - C++ Permission Denied Error clang --version权限被拒绝错误 - clang --version permission denied error 找不到权限被拒绝的opencv / lib - cannot find permission denied opencv/lib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM