Qt World Summit: Submit your Presentation

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: 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 resolve SSL_set_alpn_protos

    qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb

    qt.network.ssl: QSslSocket: cannot resolve SSL_get0_alpn_selected

    I run a Windows 7 machine, with openssl 1.1.0 installed on my D: drive. And I am using 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.
    # 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 \
    HEADERS += \
        server.h \
        commands.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";
        QNetworkReply* reply = networkManager.get(QNetworkRequest(url));
                    , &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());
        return temp;

    I kept getting the qt.network.ssl errors, and after linking openssl I keep getting a compile error:

    :-1: error: cannot find D:\OpenSSL-Win32\lib: Permission denied

    :-1: error: cannot find -llibssl

    collect2.exe:-1: error: error: ld returned 1 exit status

    Even though I am not currently using OpenSSL, I am willing to use it later.

  • Lifetime Qt Champion


    Qt is loading the SSL library dynamic at runtime, so you don't need to link against.

    IIRC, Qt 5.9 only supports OpenSSL 1.0, as 1.1 is binary incompatible.

  • I just reinstalled version 0.9 and removed links, still getting the errors, and I am not getting any answer from the http request @aha_1980

  • @Kosta maybe this post can help a little. I guess you're missing files libeay32.dll, libssl32.dll and
    ssleay32.dll available to your application in the path (it's usual to copy them in same folder as your .exe)

  • Lifetime Qt Champion


    As @aha_1980 wrote, Qt 5.9 supports the 1.0 series. You should use the latest of it. There's no reason to use an outdated and unsupported version like 0.9.

    On a side note, why not print something in case of an error to have a clue about what is happening ?
    The reply also provides an error signal that you should connect to.

  • C:\Qt\your version QT\Tools\mingw491_32\opt\bin : libeay32.dll, ssleay32.dll
    copy them in same folder as your .exe

Log in to reply