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. QSslSocket: TLS initialization Failed
QtWS25 Last Chance

QSslSocket: TLS initialization Failed

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 12 Posters 59.1k Views
  • 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
    #19

    Yes, as already suggested, use OpenSSL 1.0 since it's the version that was used to build the version of Qt you are using.
    As already written, OpenSSL broke API and ABI compatibility between 1.1 and 1.0.
    It requires a different backend that is available since 5.10 but you have to select it when building Qt.

    If you want OpenSSL 1.1, you should move to Qt 5.12 as IIRC this is now the default backend.

    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
    • C Offline
      C Offline
      Crag_Hack
      wrote on last edited by
      #20

      I currently am using 5.12 which dumps the OpenSSL version mentioned before from QSslSocket::sslLibraryBuildVersionString(). Why does the Qt dynamic libraries (that's what you download to be used with Qt Creator/VS or whatever right?) only support a specific version of OpenSSL? When you use

      INCLUDEPATH += "C:\Build-OpenSSL-VC-32\include"
      

      and

      LIBS += -LC:\Build-OpenSSL-VC-32\lib -llibcrypto -llibssl
      

      why doesn't it override whatever OpenSSL was used to build Qt? After all the includes and libraries contain all the OpenSSL code right? Does Qt have to know which functions it can call within the OpenSSL libraries and therefore since API/ABI compatibility broke with 1.1 it is restricted to whatever was used to build Qt?

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

        By default, for international distribution reason, Qt is not linked to OpenSSL but dlopens the dll if available.

        And yes, the version is restricted to what was used to build Qt as with any other dependency you may have.

        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
        • C Offline
          C Offline
          Crag_Hack
          wrote on last edited by Crag_Hack
          #22

          Everything is working beautifully with Shining Light Productions OpenSSL 1.0.2q. Thanks for the help SGaist!

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Crag_Hack
            wrote on last edited by
            #23

            @SGaist said in QSslSocket: TLS initialization Failed:

            Yes, as already suggested, use OpenSSL 1.0 since it's the version that was used to build the version of Qt you are using.
            As already written, OpenSSL broke API and ABI compatibility between 1.1 and 1.0.
            It requires a different backend that is available since 5.10 but you have to select it when building Qt.
            If you want OpenSSL 1.1, you should move to Qt 5.12 as IIRC this is now the default backend.

            When you say you have to select it when building Qt your'e referring to a static build right? Is there any way to do it for whatever version of dynamic Qt Qt Creator uses? Just curious.

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

              No, static or dynamic build doesn't play a role.

              Qt and Qt Creator are two linked but independent projects so I'm not sure what you are asking here.

              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
              • C Offline
                C Offline
                Crag_Hack
                wrote on last edited by
                #25

                OK let me explain - when you use the Qt Online Installer you select for it to install 5.12 MSVC 2017 64bit or whatever you wish. That is a preconfigured dynamic build of the Qt libraries right? There's no way to change whatever OpenSSL is used for that Qt build since it's preconfigured right?

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

                  Right, you can't switch from the 1.0 to the 1.1 backend used for the reasons already explained.

                  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
                  • R Offline
                    R Offline
                    Ross
                    wrote on last edited by
                    #27

                    I should like to add as a warning to future folks, which may include myself, that matching the exact version that your Qt libraries are using may be absolutely necessary. Look on the qt wiki for the version of openssl that was compiled against. The page will be of the form https://wiki.qt.io/Qt_5.12_Tools_and_Versions . Once you find your version, one of the links from https://wiki.openssl.org/index.php/Binaries points to https://indy.fulgan.com/SSL/ which has older binaries.

                    G 1 Reply Last reply
                    4
                    • R Ross

                      I should like to add as a warning to future folks, which may include myself, that matching the exact version that your Qt libraries are using may be absolutely necessary. Look on the qt wiki for the version of openssl that was compiled against. The page will be of the form https://wiki.qt.io/Qt_5.12_Tools_and_Versions . Once you find your version, one of the links from https://wiki.openssl.org/index.php/Binaries points to https://indy.fulgan.com/SSL/ which has older binaries.

                      G Offline
                      G Offline
                      Gwenael
                      wrote on last edited by
                      #28

                      @Ross Thank Ross this was exactly my problem : I tried with the 1.1.1 versions of libeay32.dll and ssleay32.dll. With 1.0.2p version (used with Qt5.13 beta) it works perfectly.

                      Note to other previous answers : no need to add anything in the includepath of the .pro file. Juste add the RIGHT dll's in the same directory than the executable .

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Rishabh3354
                        wrote on last edited by
                        #29

                        steps:

                        1- Firstly you need to find your SSL version for your windows machine( SSL version strictly depends on QT versions) with this function:

                        qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();
                        
                        1. After that run your code and call the above function. It will print your required SSL version in application output. In my case, it was “OpenSSL 1.0.2p 14 Aug 2018” “” which may be different for all the users.

                        2. Download SSL libraries from here

                        4- Paste all the files/content of SSL folder (which you have extracted) into the build directory inside the debug folder.

                        1. if you have doubt. then visit this post for complete info.
                        N 1 Reply Last reply
                        4
                        • R Rishabh3354

                          steps:

                          1- Firstly you need to find your SSL version for your windows machine( SSL version strictly depends on QT versions) with this function:

                          qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();
                          
                          1. After that run your code and call the above function. It will print your required SSL version in application output. In my case, it was “OpenSSL 1.0.2p 14 Aug 2018” “” which may be different for all the users.

                          2. Download SSL libraries from here

                          4- Paste all the files/content of SSL folder (which you have extracted) into the build directory inside the debug folder.

                          1. if you have doubt. then visit this post for complete info.
                          N Offline
                          N Offline
                          Neptilo
                          wrote on last edited by
                          #30

                          @Rishabh3354 said in QSslSocket: TLS initialization Failed:

                          1. Download SSL libraries from here

                          Or from here for 1.1.x builds.

                          By the way, thank you for the summarized step-by-step solution.

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            DkDkDk
                            wrote on last edited by
                            #31

                            Recently I ran into this problem, Solution I found is .

                            • Open Qt MaintenanceTool

                            • select and install OpenSLL form list

                            • got to .pro file remove old SSL libs and include path from there

                            • Add following libs for OpenSll 1.1.1 d

                            MSVC_PATH  = "C:/Qt/Qt5.14/5.14.1/mingw73_64"
                            LIBS += -L$$MSVC_PATH/../../Tools/OpenSSL/Win_x64/lib -lcrypto -lssl
                            INCLUDEPATH+= $$MSVC_PATH/../../Tools/OpenSSL/Win_x64/include 
                            

                            Changes need to do in is code some old openssl functions are to directly accessible.

                            W 1 Reply Last reply
                            1
                            • D DkDkDk

                              Recently I ran into this problem, Solution I found is .

                              • Open Qt MaintenanceTool

                              • select and install OpenSLL form list

                              • got to .pro file remove old SSL libs and include path from there

                              • Add following libs for OpenSll 1.1.1 d

                              MSVC_PATH  = "C:/Qt/Qt5.14/5.14.1/mingw73_64"
                              LIBS += -L$$MSVC_PATH/../../Tools/OpenSSL/Win_x64/lib -lcrypto -lssl
                              INCLUDEPATH+= $$MSVC_PATH/../../Tools/OpenSSL/Win_x64/include 
                              

                              Changes need to do in is code some old openssl functions are to directly accessible.

                              W Offline
                              W Offline
                              Walmont
                              wrote on last edited by
                              #32

                              @DkDkDk Thanks dude. I solved my problem thanks to you.

                              1 Reply Last reply
                              0
                              • L Offline
                                L Offline
                                Luc4
                                wrote on last edited by
                                #33

                                For those looking for other answers, I had a similar problem. SSL was not working only on some machines, where libssl and libcrypto were properly installed. Problem was related to a missing dependency of libssl/libcrypto. If the Qt app is working, libssl/libcrypto are present and version is correct, also confirm that their deps are present.

                                1 Reply Last reply
                                0
                                • PadawanP Offline
                                  PadawanP Offline
                                  Padawan
                                  wrote on last edited by
                                  #34

                                  For anyone wondering, i'm using Qt 5.15.2 and i just downloaded OpenSSL 1.1.1k here and installed it, and added(prepended) it to Qt PATH in project pane, it didn't work when i went into system variables and put it there. Go to Projects Pane in Qt, click on 'details' in Build Environment part, then scroll down to path and select it, click on prepend path and put in the bin directory of your OPENSSL installation which was located in Program Files in my hard driveac8c3e1e-052d-4ffb-9823-c3998474ac73-image.png

                                  Ningen

                                  1 Reply Last reply
                                  2

                                  • Login

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