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. "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed
Forum Updated to NodeBB v4.3 + New Features

"qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 6 Posters 2.8k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #10

    That's because the dlls cannot be found at run time hence the empty "Loaded Version".

    Go to the Run part of the Project panel and add the path to were the dlls are to the PATH environment variable.

    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
    0
    • keksi venksiK Offline
      keksi venksiK Offline
      keksi venksi
      wrote on last edited by keksi venksi
      #11

      @SGaist Which dll's ? openSSL one

      I have added this "C:\Qt\Qt5.15\Tools\OpenSSLv3\Win_x64\bin" one into path in both environmental variables and in project run's build environment as well

      image.png

      but dlls name's have an extra point that it has version name in it as libcrypto-3-x64.dll libssl-3-x64.dll

      66d4df4a-fd46-4599-b676-ee3c2724048f-image.png

      B 1 Reply Last reply
      0
      • keksi venksiK Offline
        keksi venksiK Offline
        keksi venksi
        wrote on last edited by
        #12
        This post is deleted!
        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #13

          Hi, one other thing you can try is to build and run the "Secure Socket Client Example" in Qt's examples. (it's included both in Qt 5.14 and 5.15.) Make sure you run in it Release mode (not Debug).
          If that example works, then maybe you can copy the files from it...

          keksi venksiK 1 Reply Last reply
          0
          • keksi venksiK keksi venksi

            @SGaist Which dll's ? openSSL one

            I have added this "C:\Qt\Qt5.15\Tools\OpenSSLv3\Win_x64\bin" one into path in both environmental variables and in project run's build environment as well

            image.png

            but dlls name's have an extra point that it has version name in it as libcrypto-3-x64.dll libssl-3-x64.dll

            66d4df4a-fd46-4599-b676-ee3c2724048f-image.png

            B Offline
            B Offline
            Bonnie
            wrote on last edited by
            #14

            @keksi-venksi Here it is, since you are using Qt5.15.2, according to the Qt source code (https://code.qt.io/cgit/qt/qtbase.git/tree/src/network/ssl/qsslsocket_openssl_symbols.cpp?h=v5.15.2#n683)

                tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX),
                                             QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), result);
            

            It will only find v1.1.x of openssl.

            keksi venksiK 1 Reply Last reply
            0
            • hskoglundH hskoglund

              Hi, one other thing you can try is to build and run the "Secure Socket Client Example" in Qt's examples. (it's included both in Qt 5.14 and 5.15.) Make sure you run in it Release mode (not Debug).
              If that example works, then maybe you can copy the files from it...

              keksi venksiK Offline
              keksi venksiK Offline
              keksi venksi
              wrote on last edited by
              #15

              @hskoglund said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:

              Secure Socket Client Example

              900e88cc-6a3b-4021-afaa-4c1fa109c87f-image.png

              That example itself not working in my qt 5.14.2

              1 Reply Last reply
              0
              • B Bonnie

                @keksi-venksi Here it is, since you are using Qt5.15.2, according to the Qt source code (https://code.qt.io/cgit/qt/qtbase.git/tree/src/network/ssl/qsslsocket_openssl_symbols.cpp?h=v5.15.2#n683)

                    tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX),
                                                 QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), result);
                

                It will only find v1.1.x of openssl.

                keksi venksiK Offline
                keksi venksiK Offline
                keksi venksi
                wrote on last edited by
                #16

                @Bonnie said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:

                tryToLoadOpenSslWin32Library

                how to call this method.

                its present in a private class

                Please show some code to execute it

                B SGaistS 2 Replies Last reply
                0
                • keksi venksiK keksi venksi

                  @Bonnie said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:

                  tryToLoadOpenSslWin32Library

                  how to call this method.

                  its present in a private class

                  Please show some code to execute it

                  B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by
                  #17

                  @keksi-venksi This is Qt's internal source code, you are not supposed to use it. I post it to show that it is hard coded to load openssl v1.1.x only.

                  1 Reply Last reply
                  0
                  • keksi venksiK keksi venksi

                    @Bonnie said in "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" even though SSL is installed:

                    tryToLoadOpenSslWin32Library

                    how to call this method.

                    its present in a private class

                    Please show some code to execute it

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #18

                    @keksi-venksi why did you install OpenSSL v3 since you need v1.1 ?

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

                    B 1 Reply Last reply
                    0
                    • keksi venksiK keksi venksi

                      @SGaist

                      if (QSslSocket::supportsSsl()) {
                      qDebug() << "SSL is supported.";
                      } else {
                      qDebug() << "SSL is not supported.";
                      qDebug() << "Build Version:" << QSslSocket::sslLibraryBuildVersionString();
                      qDebug() << "Loaded Version:" << QSslSocket::sslLibraryVersionString();
                      }

                      The above code returned a value of
                      SSL is not supported.
                      Build Version: "OpenSSL 1.1.1d 10 Sep 2019"
                      Loaded Version:
                      ""

                      Im using both qt 5.14.2 and qt5.15.2

                      If i print it in Qt5.14.2 the open ssl version is OpenSSL 1.1.1d
                      If i print it in Qt5.15.2 the open ssl version is OpenSSL 1.1.1g

                      My cmd output it
                      openssl version
                      OpenSSL 1.1.1q 5 Jul 2022

                      I installed in the C folder "C:\Qt\Qt5.15\5.15.2"

                      Also I would like to puts some debugging notes

                      When I use HTTPS:somelink , the reply is TLS initialization failed.
                      but when I use HTTP:somelink the reply is fine

                      Ronel_qtmasterR Offline
                      Ronel_qtmasterR Offline
                      Ronel_qtmaster
                      wrote on last edited by Ronel_qtmaster
                      #19

                      @keksi-venksi you need to download openssl 1.1.1 on windows.
                      When done , copy libssl-1_1-x64.dll and libcrypto-1_1-x64.dll in your qt installation folder, mine is
                      C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin
                      After that it will work

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        @keksi-venksi why did you install OpenSSL v3 since you need v1.1 ?

                        B Offline
                        B Offline
                        Bonnie
                        wrote on last edited by
                        #20

                        @SGaist Well as I check Qt online installer only provides openssl v3 now...

                        SGaistS 1 Reply Last reply
                        0
                        • B Bonnie

                          @SGaist Well as I check Qt online installer only provides openssl v3 now...

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #21

                          @Bonnie I have not factored that into account but in the absolute, if not provided by the installer I would go get the official libraries.

                          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
                          0

                          • Login

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