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. QNetworkAccessManager to a HTTPS troubles
Qt 6.11 is out! See what's new in the release blog

QNetworkAccessManager to a HTTPS troubles

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 4 Posters 8.0k Views 3 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.
  • R reonZ

    I am trying to connect to a secure website and am having trouble understanding the steps to get there, i think i am supposed to use QSslSocket, which i try to do, but then i get this error when i use QSslSocket::connectToHostEncrypted:

    qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

    What am i missing ?

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by
    #11

    Relevant bugreports:
    https://bugreports.qt.io/browse/QTBUG-72015
    https://bugreports.qt.io/browse/QTBUG-72016

    Basically you can get that if you have misconfigured the socket - no private key, or local certificate. The error is nondescriptive, so you need to make sure (if you use any of those two) that both exist and are valid, and you do that manually. Could you provide the snippet you use to connect to said server?

    Read and abide by the Qt Code of Conduct

    R 1 Reply Last reply
    0
    • JKSHJ JKSH

      @reonZ said in QNetworkAccessManager to a HTTPS troubles:

      I did put it in my windows PATH, tried both the C:\OpenSSL-Win32\bin and C:\OpenSSL-Win64\bin version just in case and i still have the same error

      1. Are you using 32-bit or 64-bit Qt?
      2. Where did you download OpenSSL from?
      3. What does QSslSocket::sslLibraryBuildVersionString() return?
      4. What does QSslSocket::sslLibraryVersionString() return?

      (i restarted Qt each time).

      I'm not 100% sure, but you'll also need to make sure that Windows has recorded the changes. Did you close all the Windows dialogs after changing the settings?

      R Offline
      R Offline
      reonZ
      wrote on last edited by
      #12

      @JKSH

      1/ In Qt creator it says Based on Qt 5.12.0 (MVSC 2015, 32 bit)
      2/ From here http://slproweb.com/products/Win32OpenSSL.html
      3/ QSslSocket::sslLibraryBuildVersionString() returns OpenSSL 1.0.2p 14 Aug 2018
      4/ QSslSocket::sslLibraryVersionString() returns empty

      And yes, i made sure to close all the dialog windows before restarting Qt.

      JKSHJ 1 Reply Last reply
      0
      • kshegunovK kshegunov

        Relevant bugreports:
        https://bugreports.qt.io/browse/QTBUG-72015
        https://bugreports.qt.io/browse/QTBUG-72016

        Basically you can get that if you have misconfigured the socket - no private key, or local certificate. The error is nondescriptive, so you need to make sure (if you use any of those two) that both exist and are valid, and you do that manually. Could you provide the snippet you use to connect to said server?

        R Offline
        R Offline
        reonZ
        wrote on last edited by
        #13

        @kshegunov My test code is pretty bare right now, i just wanted to see how it worked first, it is just a simple QNetworkAccessManager::get on https://www.google.com.

        kshegunovK 1 Reply Last reply
        0
        • R reonZ

          @kshegunov My test code is pretty bare right now, i just wanted to see how it worked first, it is just a simple QNetworkAccessManager::get on https://www.google.com.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #14

          It works yes, if it's configured properly. However: QSslSocket::sslLibraryVersionString() shouldn't return empty. I'd guess Qt can't find to load your openssl library.

          Read and abide by the Qt Code of Conduct

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

            Hi,

            Following item 3, Qt was built using OpenSSL 1.0.2 so you have to download the most recent version of the 1.0 series of OpenSSL. You can't use 1.1 in this case because they broke API and ABI compatibility.

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

            R 1 Reply Last reply
            3
            • SGaistS SGaist

              Hi,

              Following item 3, Qt was built using OpenSSL 1.0.2 so you have to download the most recent version of the 1.0 series of OpenSSL. You can't use 1.1 in this case because they broke API and ABI compatibility.

              R Offline
              R Offline
              reonZ
              wrote on last edited by reonZ
              #16

              @SGaist Installed 1.0.2q and still the same, QSslSocket::sslLibraryVersionString() returns empty. I am loosing hope :(

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

                Go to the Run part of the Project panel and modify the PATH environment variable there to also contain the path to your 1.0 version of OpenSSL dlls.

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

                R 1 Reply Last reply
                0
                • SGaistS SGaist

                  Go to the Run part of the Project panel and modify the PATH environment variable there to also contain the path to your 1.0 version of OpenSSL dlls.

                  R Offline
                  R Offline
                  reonZ
                  wrote on last edited by
                  #18

                  @SGaist Sadly it is already there, even twice for some reason.

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

                    Then I would ensure that this folder is the first to appear in the list and also that there are no other versions of OpenSSL on the system, for example in the Windows specific folders.

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

                    R 1 Reply Last reply
                    2
                    • SGaistS SGaist

                      Then I would ensure that this folder is the first to appear in the list and also that there are no other versions of OpenSSL on the system, for example in the Windows specific folders.

                      R Offline
                      R Offline
                      reonZ
                      wrote on last edited by
                      #20

                      @SGaist Alright it is working now, i indeed needed to install the 64bit version and not the 32 bit:

                      QSslSocket::sslLibraryBuildVersionString()   "OpenSSL 1.0.2p  14 Aug 2018"
                      QSslSocket::sslLibraryVersionString()        "OpenSSL 1.0.2q  20 Nov 2018"
                      

                      I also received the result from QNetworkAccessManager::get

                      Thanks a lot for all the help, you guys are awesome.

                      Edit: i still always have this in the output console though QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once but it is not related to this because i had it on non secure get too.

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

                        The message will be gone in 5.12.2. See QTBUG-72463

                        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
                        • R reonZ

                          @JKSH

                          1/ In Qt creator it says Based on Qt 5.12.0 (MVSC 2015, 32 bit)
                          2/ From here http://slproweb.com/products/Win32OpenSSL.html
                          3/ QSslSocket::sslLibraryBuildVersionString() returns OpenSSL 1.0.2p 14 Aug 2018
                          4/ QSslSocket::sslLibraryVersionString() returns empty

                          And yes, i made sure to close all the dialog windows before restarting Qt.

                          JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on last edited by
                          #22

                          I'm glad to hear that it's working for you now!

                          @reonZ said in QNetworkAccessManager to a HTTPS troubles:

                          3/ QSslSocket::sslLibraryBuildVersionString() returns OpenSSL 1.0.2p 14 Aug 2018

                          Apologies, I gave you wrong information earlier. This result shows that Qt was built against OpenSSL 1.0.2, not 1.1.0.

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          1 Reply Last reply
                          0

                          • Login

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