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. openSSL in QT
QtWS25 Last Chance

openSSL in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 6.4k 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.
  • S Offline
    S Offline
    saeid0034
    wrote on last edited by
    #1

    sorry if this question asked before
    anyone can help me to how use openssl in a project without need to build qt with openssl?
    im want to post data to my https site
    but its say qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
    how can i fix this

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

      Hi,

      The usual first step is to install OpenSSL.

      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
      • S Offline
        S Offline
        saeid0034
        wrote on last edited by
        #3

        i want to use it on QNetworkReques and it everytime give me this error
        i build openssl by myself and add lib to my project but nothing changed
        i try to use precompiled openssl too but i still get same error

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

          Which OS ?
          Which version of Qt ?
          Which version of OpenSSL ?
          How did you install Qt ?

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

          S 1 Reply Last reply
          1
          • SGaistS SGaist

            Which OS ?
            Which version of Qt ?
            Which version of OpenSSL ?
            How did you install Qt ?

            S Offline
            S Offline
            saeid0034
            wrote on last edited by
            #5

            @SGaist
            window
            QT 5.15.0
            i test multi version like 1.1.1g, openssl-1.0.2a, and also precompiled openssl-1.1.1g-win64-mingw
            i have two version of Qt
            one i install normally from site (via installer)
            and Qt static

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

              So I guess you are also using the MinGW build of Qt ?

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

              S 1 Reply Last reply
              1
              • SGaistS SGaist

                So I guess you are also using the MinGW build of Qt ?

                S Offline
                S Offline
                saeid0034
                wrote on last edited by
                #7

                @SGaist yes
                i have mingw version
                i also try openssl from this site

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

                  Did you check that you have everything from the right architecture ?

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

                  S 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Did you check that you have everything from the right architecture ?

                    S Offline
                    S Offline
                    saeid0034
                    wrote on last edited by
                    #9

                    @SGaist yes, i build openssl by qt mingw

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      saeid0034
                      wrote on last edited by
                      #10

                      when i check ssl version of qt with QSslSocket::sslLibraryBuildVersionString() it say "OpenSSL 1.1.1d 10 Sep 2019"
                      its mean i need to build version 1.1.1d?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        saeid0034
                        wrote on last edited by saeid0034
                        #11

                        i build openssl version 1.1.1d too
                        and add lib to my project
                        but still no luck
                        here my code and error
                        2ac46222-1eee-42a2-a011-3421031a792c-image.png

                        and also openssl part in pro file

                        win32: LIBS += -LD:/build/ver-1d-openssl/lib/ -lcrypto
                        win32: LIBS += -LD:/build/ver-1d-openssl/lib/ -lssl
                        
                        INCLUDEPATH += D:/build/ver-1d-openssl/include
                        DEPENDPATH += D:/build/ver-1d-openssl/include
                        

                        edit: when i add openssl dll in debug folder of my project its work just fine
                        but i need static

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

                          Your application does not link to OpenSSL nor does Qt by default.

                          As for when running your application, the dlls must be findable. The usual way is to copy the files in the same folder as your application or modify the PATH environment variable in the Run part of the Project panel.

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

                          S 1 Reply Last reply
                          3
                          • SGaistS SGaist

                            Your application does not link to OpenSSL nor does Qt by default.

                            As for when running your application, the dlls must be findable. The usual way is to copy the files in the same folder as your application or modify the PATH environment variable in the Run part of the Project panel.

                            S Offline
                            S Offline
                            saeid0034
                            wrote on last edited by
                            #13

                            @SGaist yes by adding dll in exe folder im able to post data
                            but there is anyway to include openssl static?

                            jsulmJ 1 Reply Last reply
                            0
                            • S saeid0034

                              @SGaist yes by adding dll in exe folder im able to post data
                              but there is anyway to include openssl static?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @saeid0034 said in openSSL in QT:

                              but there is anyway to include openssl static?

                              Not without building Qt by yourself as normal Qt builds load OpenSSL libs at runtime.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              S 1 Reply Last reply
                              4
                              • jsulmJ jsulm

                                @saeid0034 said in openSSL in QT:

                                but there is anyway to include openssl static?

                                Not without building Qt by yourself as normal Qt builds load OpenSSL libs at runtime.

                                S Offline
                                S Offline
                                saeid0034
                                wrote on last edited by saeid0034
                                #15

                                @jsulm can anyone tell me i need to pass what in ./configure to build qt with openssl statically
                                i use this for build qt static for now

                                configure -opensource -confirm-license -static -platform win32-g++ -optimize-size -opengl desktop -prefix "C:\Qt\static" -skip webengine -nomake tests -nomake examples -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -qt-tiff

                                i need to add what to build qt static + openssl?

                                edit: i see this page in wiki
                                based of this page i need to build qt like this

                                OPENSSL_LIBS='-L/d/build/ssl/lib -lssl -lcrypto' && configure -opensource -confirm-license -static -platform win32-g++ -openssl-linked -optimize-size -opengl desktop -prefix "C:\Qt\static" -skip webengine -nomake tests -nomake examples -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -qt-tiff

                                in this configure OPENSSL_LIBS is Location of openssl-1.1.1g i compiled before (with mingw)

                                its all ok?

                                jsulmJ 1 Reply Last reply
                                0
                                • S saeid0034

                                  @jsulm can anyone tell me i need to pass what in ./configure to build qt with openssl statically
                                  i use this for build qt static for now

                                  configure -opensource -confirm-license -static -platform win32-g++ -optimize-size -opengl desktop -prefix "C:\Qt\static" -skip webengine -nomake tests -nomake examples -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -qt-tiff

                                  i need to add what to build qt static + openssl?

                                  edit: i see this page in wiki
                                  based of this page i need to build qt like this

                                  OPENSSL_LIBS='-L/d/build/ssl/lib -lssl -lcrypto' && configure -opensource -confirm-license -static -platform win32-g++ -openssl-linked -optimize-size -opengl desktop -prefix "C:\Qt\static" -skip webengine -nomake tests -nomake examples -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -qt-tiff

                                  in this configure OPENSSL_LIBS is Location of openssl-1.1.1g i compiled before (with mingw)

                                  its all ok?

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @saeid0034 said in openSSL in QT:

                                  OPENSSL_LIBS='-L/d/build/ssl/lib -lssl -lcrypto

                                  This looks like linking against shared OpenSSL libs.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  S 1 Reply Last reply
                                  1
                                  • jsulmJ jsulm

                                    @saeid0034 said in openSSL in QT:

                                    OPENSSL_LIBS='-L/d/build/ssl/lib -lssl -lcrypto

                                    This looks like linking against shared OpenSSL libs.

                                    S Offline
                                    S Offline
                                    saeid0034
                                    wrote on last edited by saeid0034
                                    #17

                                    @jsulm you say i do not need to set OPENSSL_LIBS?
                                    and by the way i think this 2 lib use for shared version libssl.dll.a & libcrypto.dll.a

                                    and also i use mingw to build openssl and Qt

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      Markus43
                                      wrote on last edited by
                                      #18

                                      You don't need to rebuild Qt. Just select OpenSSL in the installer, and do what is suggested here:

                                      https://stackoverflow.com/questions/59507538/install-openssl-for-msvc2017-on-64-bit-windows-10

                                      S 1 Reply Last reply
                                      1
                                      • M Markus43

                                        You don't need to rebuild Qt. Just select OpenSSL in the installer, and do what is suggested here:

                                        https://stackoverflow.com/questions/59507538/install-openssl-for-msvc2017-on-64-bit-windows-10

                                        S Offline
                                        S Offline
                                        saeid0034
                                        wrote on last edited by
                                        #19

                                        @Markus43 thanks for reply, but i need openssl for static build

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          Markus43
                                          wrote on last edited by
                                          #20

                                          Then the question is: Does OpenSSL need to be static, too?

                                          If you can live with using OpenSSL dlls while using static Qt, you can just add the following to your configure line (also with OpenSSL from the installer) and you're done.
                                          e.g. for x86 builds:

                                          -openssl -I C:\Qt\Tools\OpenSSL\Win_x86\include -L C:\Qt\Tools\OpenSSL\Win_x86\lib
                                          
                                          S 1 Reply Last reply
                                          1

                                          • Login

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