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
    #2

    Hi,

    Which version of Qt are you using ?

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

    D 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Which version of Qt are you using ?

      D Offline
      D Offline
      Donald Duck
      wrote on last edited by
      #3

      @SGaist I'm using 5.15.2.

      SGaistS 1 Reply Last reply
      0
      • D Donald Duck

        @SGaist I'm using 5.15.2.

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

        Then that is your issue, Qt 5.15.2 supports OpenSSL 1.1

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

        D 1 Reply Last reply
        1
        • SGaistS SGaist

          Then that is your issue, Qt 5.15.2 supports OpenSSL 1.1

          D Offline
          D Offline
          Donald Duck
          wrote on last edited by
          #5

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

          SGaistS 1 Reply Last reply
          0
          • D Donald Duck

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

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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
            • keksi venksiK Offline
              keksi venksiK Offline
              keksi venksi
              wrote on 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

              SGaistS 1 Reply Last reply
              0
              • keksi venksiK keksi venksi

                @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

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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
                • keksi venksiK Offline
                  keksi venksiK Offline
                  keksi venksi
                  wrote on 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

                  Ronel_qtmasterR 1 Reply Last reply
                  0
                  • 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 Online
                          hskoglundH Online
                          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