Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. connectToHostEncrypted: TLS initialization failed
Forum Updated to NodeBB v4.3 + New Features

connectToHostEncrypted: TLS initialization failed

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ana_Ichi
    wrote on last edited by
    #1

    I tried to make a request for a free API.
    t is very simple.
    And i got an error:

    connectToHostEncrypted: TLS initialization failed

    It's my first time doing this. I will really appriciate if you please can help me to fix it .

    QNetworkAccessManager mMananger;
    
    QUrlQuery query;
       query.addQueryItem("page", "2");
    

    //declaracion de la URL por parte
    QUrl urlPage;
    urlPage.setScheme("https");
    urlPage.setHost("reqres.in"); /
    urlPage.setPath("/api/users");
    urlPage.setQuery(query);

       QNetworkRequest mRequest;
       mRequest.setUrl(urlPage);
    
    //almacena la respuesta
    QNetworkReply * mReply= mMananger.get(mRequest);
    
    
    
    QObject::connect(mReply,&QNetworkReply::finished,[&](){
     
        QMetaEnum metaEnum = QMetaEnum::fromType<QNetworkReply::NetworkError>();
        qDebug() << "Error" << metaEnum.valueToKey(mReply->error());
    
        QByteArray read =mReply->readAll();
    
        std::cout << "Got response:\n"
                  <<read.toStdString()<<std::endl;
        mReply->close();
        mReply->deleteLater();
    
    
    });```
    
    I am using 
    Qt5.15.2 
    MSCV2019 de 64bits 
    OS Window10
    
    Thank you
    1 Reply Last reply
    0
    • A Offline
      A Offline
      Ana_Ichi
      wrote on last edited by
      #7

      Thank you very much for all your answers.
      I took the easy way using maintenance tool.
      and it worked very well

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        Did you forgot to install OpenSSL ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • A Offline
          A Offline
          Ana_Ichi
          wrote on last edited by Ana_Ichi
          #3

          hi, thanks for answering, I am new in this.
          How can i do that?

          i follow the solution of someone else and I already tried to solve it but it is too old.
          i downloaded the installer from
          Web Site
          and selected de option for 64 bits for developers

          after that i included in the .pro file:

          LIBS += -LC:/Program Files/OpenSSL-Win64/lib -lubsec
          
          INCLUDEPATH += C:/OpenSSL-Win64/include
          

          and then in the main file

          #include <openssl/aes.h>
          

          but still doesn´t work i looked in the folder lib and i didn´t see a file named ubsec.lib

          C 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #4

            You can get OpenSSL through Qt's installer.

            You also have to make she the compiler used to build it matches the one you are using.

            It's a C library, so you are safe compiler wise.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • oria66O Offline
              oria66O Offline
              oria66
              wrote on last edited by
              #5

              Hi @Ana_Ichi.

              You can read an extensive entry here https://forum.qt.io/topic/95700/qsslsocket-tls-initialization-failed.

              It seems kind of funny because there are so many answers through time. Anyway, this works for me, you can test it in Windows:

              1. Install OpenSSL from Maintenance Tool.

              62270ee4-db0f-4054-903f-bc925d6f3afe-image.png

              2. Independently of your compiler, go to C:\Qt\Tools\OpenSSL\Win_x64\bin (if you have 64 bits application).

              3. Copy libcrypto-1_1-x64.dll and libssl-1_1-x64.dll and paste in your release or debug application executable.

              5693de21-530f-436a-b8e7-151851b7af62-image.png

              Cheers,

              The truth is out there

              1 Reply Last reply
              4
              • A Ana_Ichi

                hi, thanks for answering, I am new in this.
                How can i do that?

                i follow the solution of someone else and I already tried to solve it but it is too old.
                i downloaded the installer from
                Web Site
                and selected de option for 64 bits for developers

                after that i included in the .pro file:

                LIBS += -LC:/Program Files/OpenSSL-Win64/lib -lubsec
                
                INCLUDEPATH += C:/OpenSSL-Win64/include
                

                and then in the main file

                #include <openssl/aes.h>
                

                but still doesn´t work i looked in the folder lib and i didn´t see a file named ubsec.lib

                C Offline
                C Offline
                ChrisW67
                wrote on last edited by ChrisW67
                #6

                @Ana_Ichi said in connectToHostEncrypted: TLS initialization failed:

                LIBS += -LC:/Program Files/OpenSSL-Win64/lib -lubsec

                I think you will need quotes around that path.

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  Ana_Ichi
                  wrote on last edited by
                  #7

                  Thank you very much for all your answers.
                  I took the easy way using maintenance tool.
                  and it worked very well

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved