[Solved] QNetWorkRequest SSL



  • How can I make my QwebView/QNetWorkRequest work with SSL?

    QT return this errors (is clear that the error occurs because I did not configure SSL in my application):

    bq. QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
    QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
    QSslSocket: cannot call unresolved function OPENSSL_add_all_algorithms_conf

    I am use Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL) - my window is 64bit

    I try ( http://stackoverflow.com/a/12769375/1518921 ):

    @ myNAM *m_network;

    QNetworkReply * myNAM::createRequest(
        Operation op,
        const QNetworkRequest &request,
        QIODevice *outgoingData
    ){
        QNetworkRequest req(request);
    
     QSslConfiguration conf = req.sslConfiguration();
        conf.setProtocol(QSsl::TlsV1SslV3);
     req.setSslConfiguration(conf);
    
     QNetworkAccessManager::createRequest(
            op,
            QNetworkRequest(request),
            outgoingData
        );
    }@
    

    I'll be honest, I have no idea where to start.
    I searched but have not found anywhere that shows how trabalar SSL with QNetWorkRequest.



  • Try to place openssl libraries near executable. I have two files - libeay32.dll and ssleay.dll.
    Connect such slot to sslErrors signal of NetworkAccessManager
    @void NAM::sslErrorsSlot(QNetworkReply *reply, const QList<QSslError> &errors)
    {
    reply->ignoreSslErrors();
    }@

    to ignore any errors during ssl communication.

    Also, function createRequest in your code example doesn't return value(that could compile and lead to a problem).



  • Thanks kdkdkd by answer!

    But are you sure that ignoreSslErros() is the right way to solve this problem?

    I install openSslWin32 (my Windows is 64bit, but my application is 32bit), I try this:

    pro file:
    @LIBS += -LC:/OpenSSL-Win32/lib -lubsec
    INCLUDEPATH += C:/OpenSSL-Win32/include@

    cpp file:
    @#include <openssl/aes.h>@

    but continues to show errors:
    @QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
    QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
    QSslSocket: cannot call unresolved function OPENSSL_add_all_algorithms_conf@

    forgive me I'm beginner.



  • Can you try to find libeay32.dll and ssleay.dll in your ssl distribution, and put them in same folder, where your executable gets created?
    For me it is sufficient to do that to make qt work with ssl, no need to include anything.



  • Nice tip, but I could not run, continues to show errors.
    Tell me please, I need to add some instruction within my project to load the dlls? Or just copy the dlls to "build" (release / debug) folder?

    I try this

    @LIBS += -LC:/OpenSSL-Win32/lib -lubsec -lws2_32 -llibeay32 -lgdi32@

    and the errors stopped, but just in case, this is correct? Or would it be better to add some "DLL" the most? Thanks!



  • No, you don't need to link any libraries, and to make any includes and write no single line of config. Qt searches for openssl at runtime. If the problem was in missed include you will get compile error. If the problem was in missed library - you will get linker error(undefined reference). But you have runtime messages. I distributed application just with dll inside archive with no additional instruction or installer.

    There is strange, that qt can't find exactly OPENSSL_add_all_algorithms_noconf, because when I remove dlls from my folder - it shows other unresolved.

    bq. QSslSocket: cannot call unresolved function SSLv23_client_method
    QSslSocket: cannot call unresolved function SSL_CTX_new
    QSslSocket: cannot call unresolved function SSL_library_init
    QSslSocket: cannot call unresolved function ERR_get_error
    QSslSocket: cannot call unresolved function ERR_get_error

    I also tried to make network request on clear vm and it worked. I have several suggestions:

    • Try to delete dlls during application run. If system allows that - than qt doesn't see these libraries.
    • Search for OPENSSL_add_all_algorithms_noconf inside libeay32.dll. Mine has one.
    • Show output of QSslSocket::supportsSsl() function


  • Thanks for all the tips, apparently when I installed OpenSSL on windows, it caused conflict with QtSDK, I'm reinstalling everything and clearing the logs and then I will try your suggestion.

    [edit]
    I am install OpenSSL 32bit (My windows is 64bit), is now working.

    Download precompiled for Windows: http://slproweb.com/products/Win32OpenSSL.html

    Version downloaded: http://slproweb.com/download/Win32OpenSSL-1_0_1e.exe

    In install select the option Windows system directory.

    But I'll try your "method". Thanks!

    Solved!


Log in to reply
 

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