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.
  • D Donald Duck
    30 Sept 2023, 20:25

    @SGaist So does that mean that I need to upgrade to Qt 6?

    S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 30 Sept 2023, 20:48 last edited by
    #6

    No, it's not required although advised. You can get OpenSSL 1.1 and use it with 5.15.2.

    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
    1
    • D Donald Duck has marked this topic as solved on 30 Sept 2023, 21:12
    • K Offline
      K Offline
      keksi venksi
      wrote on 24 Jul 2024, 12:21 last edited by
      #7

      @SGaist Can you please help me to solve the same issue in my case

      Im using qt5.15.2 and when I try to print the sslversion its "OpenSSL 1.1.1g"

      When i try to command the openssl version in my machine its "OpenSSL 1.1.1q "

      So here it means my machine needs to match with "OpenSSL 1.1.1g" or below than that right ?

      If so can you please give me a link of downloading openssl 1.1.1g exe file

      S 1 Reply Last reply 24 Jul 2024, 15:56
      0
      • K keksi venksi
        24 Jul 2024, 12:21

        @SGaist Can you please help me to solve the same issue in my case

        Im using qt5.15.2 and when I try to print the sslversion its "OpenSSL 1.1.1g"

        When i try to command the openssl version in my machine its "OpenSSL 1.1.1q "

        So here it means my machine needs to match with "OpenSSL 1.1.1g" or below than that right ?

        If so can you please give me a link of downloading openssl 1.1.1g exe file

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 24 Jul 2024, 15:56 last edited by
        #8

        @keksi-venksi What do you get if you put:

        qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();
        in your code ?

        Changing the patch version should not be a problem to load OpenSSL.
        Where did you install it ?

        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
        • K Offline
          K Offline
          keksi venksi
          wrote on 25 Jul 2024, 07:19 last edited by keksi venksi
          #9

          @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

          R 1 Reply Last reply 25 Jul 2024, 17:22
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 25 Jul 2024, 07:33 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
            • K Offline
              K Offline
              keksi venksi
              wrote on 25 Jul 2024, 07:46 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 25 Jul 2024, 09:15
              0
              • K Offline
                K Offline
                keksi venksi
                wrote on 25 Jul 2024, 08:00 last edited by
                #12
                This post is deleted!
                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hskoglund
                  wrote on 25 Jul 2024, 08:53 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...

                  K 1 Reply Last reply 25 Jul 2024, 12:16
                  0
                  • K keksi venksi
                    25 Jul 2024, 07:46

                    @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 25 Jul 2024, 09:15 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.

                    K 1 Reply Last reply 25 Jul 2024, 13:00
                    0
                    • H hskoglund
                      25 Jul 2024, 08:53

                      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...

                      K Offline
                      K Offline
                      keksi venksi
                      wrote on 25 Jul 2024, 12:16 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
                        25 Jul 2024, 09:15

                        @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.

                        K Offline
                        K Offline
                        keksi venksi
                        wrote on 25 Jul 2024, 13:00 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 S 2 Replies Last reply 25 Jul 2024, 14:13
                        0
                        • K keksi venksi
                          25 Jul 2024, 13:00

                          @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 25 Jul 2024, 14:13 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
                          • K keksi venksi
                            25 Jul 2024, 13:00

                            @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

                            S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 25 Jul 2024, 17:07 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 26 Jul 2024, 02:28
                            0
                            • K keksi venksi
                              25 Jul 2024, 07:19

                              @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

                              R Offline
                              R Offline
                              Ronel_qtmaster
                              wrote on 25 Jul 2024, 17:22 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
                              • S SGaist
                                25 Jul 2024, 17:07

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

                                B Offline
                                B Offline
                                Bonnie
                                wrote on 26 Jul 2024, 02:28 last edited by
                                #20

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

                                S 1 Reply Last reply 26 Jul 2024, 16:48
                                0
                                • B Bonnie
                                  26 Jul 2024, 02:28

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

                                  S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 26 Jul 2024, 16:48 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

                                  15/21

                                  25 Jul 2024, 12:16

                                  • Login

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