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. Using QSslSocket with custom OpenSSL
Forum Updated to NodeBB v4.3 + New Features

Using QSslSocket with custom OpenSSL

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++ qtopensslsslwindows 10
41 Posts 9 Posters 35.3k Views 3 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.
  • V Offline
    V Offline
    VRonin
    wrote on 14 Sept 2016, 16:24 last edited by
    #2

    You cannot use the pre-built binary of Qt, you'll have to compile it yourself linking to the new OpenSSL

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    1
    • M Offline
      M Offline
      MChelik
      wrote on 14 Sept 2016, 16:42 last edited by
      #3

      That's a lot of work! So what if I want to use what Qt offers me? Why QSslSocket::supportsSsl() returns false?

      1 Reply Last reply
      0
      • M MChelik
        14 Sept 2016, 16:13

        I want to use QSslSocket and QSslCertificate with my latest OpenSSL build. I built OpenSSL 1.1.0 with VS2015 and added its bin directory into %PATH, also added its LIBS to my .pro file:

        LIBS += -LC:/openssl_1.1.0/lib/ -llibcrypto -llibssl
        

        When I run my application, QSslSocket::supportsSsl() returns false and QSslSocket::sslLibraryBuildVersionString() returns OpenSSL 1.0.2g 1 Mar 2016, even though I built OpenSSL 1.1.0. Also I get error messages like this:

        qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
        qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
        qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
        qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
        

        What is the problem? How can I use my built OpenSSL libraries and binaries?

        P.S. I use Windows 10, Qt 5.7, OpenSSL 1.1.0, Visual Studio 2015 Enterprise.

        Thank you

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 14 Sept 2016, 16:42 last edited by
        #4

        @MChelik
        Qt loads the OpenSSL libs on demand. Where the DLL name is hardcoded and the methods are resolved "manually".
        So linking against OpenSSL wont make any difference.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • M Offline
          M Offline
          MChelik
          wrote on 14 Sept 2016, 16:48 last edited by
          #5

          @raven-worx So why QSslSocket::supportsSsl() returns false? Lets forget about my custom OpenSSL.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRonin
            wrote on 14 Sept 2016, 16:56 last edited by
            #6

            did you add the OpenSSL path to PATH?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • M Offline
              M Offline
              MChelik
              wrote on 14 Sept 2016, 17:01 last edited by
              #7

              @VRonin Yes, there is libcrypto-1_1-x64.dll and libssl-1_1-x64.dll in it.

              R 1 Reply Last reply 14 Sept 2016, 17:11
              0
              • M MChelik
                14 Sept 2016, 17:01

                @VRonin Yes, there is libcrypto-1_1-x64.dll and libssl-1_1-x64.dll in it.

                R Offline
                R Offline
                raven-worx
                Moderators
                wrote on 14 Sept 2016, 17:11 last edited by
                #8

                @MChelik
                on windows they are called ssleay32.dll and libeay32.dll

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                M R 2 Replies Last reply 14 Sept 2016, 18:40
                2
                • R raven-worx
                  14 Sept 2016, 17:11

                  @MChelik
                  on windows they are called ssleay32.dll and libeay32.dll

                  M Offline
                  M Offline
                  MChelik
                  wrote on 14 Sept 2016, 18:40 last edited by
                  #9

                  @raven-worx Since QSslSocket::sslLibraryBuildVersionString() returns "OpenSSL 1.0.2g 1 Mar 2016", I downloaded OpenSSL_1.0.2g source code and compiled it, but inside bin directory there was only openssl.exe. So I copied ssleay32.dll and libeay32.dll from C:\Qt\Tools\QtCreator\bin to C:\Windows. But still I get same error, nothing changed.
                  What should I do use QSslSocket? I'm really confused. I searched a lot but nothing helped.

                  R 1 Reply Last reply 15 Sept 2016, 05:52
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 14 Sept 2016, 21:01 last edited by
                    #10

                    Hi and welcome to devnet,

                    Don't copy .dlls like that in the Windows folder, that's very bad practice.

                    If Qt shows you a different version of OpenSSL, it likely means that you have an application that also provides these files and can be found before yours.

                    I've successfully used the prebuilt packages from Shining Lights Production.

                    Hope it helps

                    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
                    3
                    • M MChelik
                      14 Sept 2016, 18:40

                      @raven-worx Since QSslSocket::sslLibraryBuildVersionString() returns "OpenSSL 1.0.2g 1 Mar 2016", I downloaded OpenSSL_1.0.2g source code and compiled it, but inside bin directory there was only openssl.exe. So I copied ssleay32.dll and libeay32.dll from C:\Qt\Tools\QtCreator\bin to C:\Windows. But still I get same error, nothing changed.
                      What should I do use QSslSocket? I'm really confused. I searched a lot but nothing helped.

                      R Offline
                      R Offline
                      raven-worx
                      Moderators
                      wrote on 15 Sept 2016, 05:52 last edited by
                      #11

                      @MChelik said in Using QSslSocket with custom OpenSSL:

                      So I copied ssleay32.dll and libeay32.dll from C:\Qt\Tools\QtCreator\bin to C:\Windows

                      don't do that, as @SGaist said. Copy them next to your application exe instead.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        MChelik
                        wrote on 16 Sept 2016, 00:21 last edited by
                        #12

                        Thank you SGaist. Copying next to application executable didn't help either.
                        Gentlemen, let's forget my OpenSSL; forget everything. Just assume that I want to use QSslSocket and QSslCertificate. What should I do? Should I compile Qt myself? Should I install OpenSSL? What should I do exactly? Qt documents doesn't say any specific thing about this. Documents say only how to use mentioned two classes.
                        Thank you

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          hskoglund
                          wrote on 16 Sept 2016, 01:06 last edited by hskoglund
                          #13

                          Hi, just a quick note on OpenSSL with Qt, I think because you're building a 64-bit Qt app that's why you're having problems. Because those 2 DLLs s stored in C:\Qt\Tools\QtCreator\bin are built with MSVC2013 32-bit compiler (same as for Qt Creator itself) so they are not kosher for 64-bit :-(

                          1 Reply Last reply
                          2
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 16 Sept 2016, 07:33 last edited by
                            #14

                            To add to @hskoglund, the prebuilt packages I've mentioned earlier also provide "OpenSSL-Win64" which are pre-built for 64bit development.

                            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
                            • M Offline
                              M Offline
                              MChelik
                              wrote on 17 Sept 2016, 23:51 last edited by
                              #15

                              @hskoglund That was my problem! I didn't pay attention to that. But I a have a question: The only libeay32.dll and ssleay32.dll files that are in my %PATH% is C:\Win64-OpenSSL\bin directory. So why my application only works when mentioned DLLs are beside my application (doesn't work when are in %PATH)?

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 18 Sept 2016, 20:03 last edited by
                                #16

                                Are you sure you don't have any other application that has these libraries and that can be found in your 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

                                M 1 Reply Last reply 19 Sept 2016, 21:08
                                1
                                • S SGaist
                                  18 Sept 2016, 20:03

                                  Are you sure you don't have any other application that has these libraries and that can be found in your PATH environment variable ?

                                  M Offline
                                  M Offline
                                  MChelik
                                  wrote on 19 Sept 2016, 21:08 last edited by
                                  #17

                                  @SGaist No, I searched my whole disk for these DLLs. Every directory that contains these DLLs is not in %PATH.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 19 Sept 2016, 21:57 last edited by
                                    #18

                                    How did you modify PATH ? In your Windows settings or in Qt Creator ?

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

                                    M 1 Reply Last reply 22 Sept 2016, 23:57
                                    0
                                    • H Offline
                                      H Offline
                                      hskoglund
                                      wrote on 19 Sept 2016, 22:04 last edited by
                                      #19

                                      Hi, also, they could be loaded via some other means than their directories being listed in %PATH%, either that some other dll that your .exe loads explicitly pulls in the bad (i.e. 32-bit) ones, or perhaps they're hiding in c:\windows or c:\windows\system32.

                                      To debug this. you could try download Dependency Walker and load your app into it. Then start profiling with F7, that'll get you a trace of all the dlls loaded.

                                      1 Reply Last reply
                                      1
                                      • N Offline
                                        N Offline
                                        Nalnalital
                                        wrote on 20 Sept 2016, 14:31 last edited by
                                        #20
                                        This post is deleted!
                                        N 1 Reply Last reply 20 Sept 2016, 15:12
                                        0
                                        • N Nalnalital
                                          20 Sept 2016, 14:31

                                          This post is deleted!

                                          N Offline
                                          N Offline
                                          Nalnalital
                                          wrote on 20 Sept 2016, 15:12 last edited by
                                          #21
                                          This post is deleted!
                                          1 Reply Last reply
                                          0

                                          11/41

                                          15 Sept 2016, 05:52

                                          topic:navigator.unread, 30
                                          • Login

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