How to add HTTPS support to QNetworkAccessManager ?

  • How do i add HTTPS/ssl support to the following code so it can work with HTTPS links ?

    Currently getting problem :
    QSslSocket: cannot call unresolved function SSL_CTX_new
    QSslSocket: cannot call unresolved function SSL_library_init
    QSslSocket: cannot call unresolved function ERR_get_error

    class MyClass : public QObject
        void fetch();
    public slots:
        void replyFinished(QNetworkReply*);
        QNetworkAccessManager* m_manager;
        m_manager = new QNetworkAccessManager(this);
        connect(m_manager, SIGNAL(finished(QNetworkReply*)),
             this, SLOT(replyFinished(QNetworkReply*)));
    void MyClass::fetch()
    void MyClass::replyFinished(QNetworkReply* pReply)
        QByteArray data=pReply->readAll();
        QString str(data);
        //process str any way you like!

    Full source:

  • Lifetime Qt Champion


    Do you have OpenSSL installed on your system ?

    Which OS are you using by the way ?

  • @SGaist using windows i've compiled qt from source with ssl support, yes i have OpenSSL installed + i have a compiled one under C:/deps/ and i added the following to .pro :


    win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat -static
    win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++

    LIBS += $$join(OPENSSL_LIB_PATH,,-L,)

    windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32

  • Lifetime Qt Champion

    If you are running Qt Creator, go to the Run part of the Project panel and check whether the path to OpenSSL's DLLs can be found in the PATH environment variable. If not, add it there (don't do it system wide)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.