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

Include OpenSSL

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 4.8k 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.
  • cubicapC Offline
    cubicapC Offline
    cubicap
    wrote on last edited by
    #1

    Hello,
    I need to use https with QNetworkManager. For that, I need OpenSSL. However, I was not able to include it in the project.
    As Qt Maintanance Tool allows installation of OpenSSL, I thought, it would be the best way to go. Though I could make SSL work only by downloading OpenSSL precompiled separately and copy the dlls (ssleay32 and libeay32) directly next to the exe.
    That worked until I wanted to deploy the program and test it in clean VM, where it can not access SSL enabled websites.

    How should I include the "bundled" OpenSSL to my project?

    I tried to add following two lines to the .pro file:

    LIBS += "C:/Qt/Tools/OpenSSL/Win_x64/lib/libssl.lib"
    LIBS += "C:/Qt/Tools/OpenSSL/Win_x64/lib/libcrypto.lib"
    

    Then I am able to include OpenSSL libraries to cpp but QNetworkManager still says QSslSocket::connectToHostEncrypted: TLS initialization failed.

    Just to clarify, I use 64-bit Windows.

    Thank you for any help.

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

      Hi,

      You need to make them available to your application at run time. Go to the Run part of the Project panel and modify there the Path environnement variable and the folder where the OpenSSL dlls can be found.

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

        Oh, thank you very much. I can now run the app with SSL working.

        How can I now deploy the app to a clean machine? Does it bundle the dlls automatically or do I have to pack OpenSSL manually?

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

          You can do that with windeployqt. You likely will have to add the OpenSSL dlls by hand. Using encryption in software hits certain restrictions in some countries so it can't be just added automatically unconditionally.

          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
          • cubicapC Offline
            cubicapC Offline
            cubicap
            wrote on last edited by
            #5

            Thank you for your help.
            Exactly as you said, I deploy it using windeployqt, copy the necessary dlls and it runs. The only thing I had to do to make it work was to install MSVC++ 2010 Runtime, which took a while to spot (there is no popup or anything to it, so I thought, it did not see the dlls).

            Now, to get rid of the MSVC, I will probably have to compile OpenSSL on my own, which I currently struggle with a bit but that's a different topic.

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

              Dependency Walker is another good tool to have to check what dependencies you may have missed.

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

              cubicapC 1 Reply Last reply
              1
              • SGaistS SGaist

                Dependency Walker is another good tool to have to check what dependencies you may have missed.

                cubicapC Offline
                cubicapC Offline
                cubicap
                wrote on last edited by
                #7

                Thank you for the tip!

                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