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 ssl and https
Forum Updated to NodeBB v4.3 + New Features

qt ssl and https

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 2.1k 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.
  • J Offline
    J Offline
    Jedd
    wrote on 11 Aug 2018, 16:25 last edited by
    #1

    I'm getting network error 301 when reading a text file from an https website. I copied ssleay32.dll and libelay32.dll alongside my exe and added CONFIG += openssl-linked into my project file. My Qt is 5.10.1, statically linked. Works fine with a http website of course.

    Most of what I read seemed to suggest that the two dlls and the openssl-linked flag would be all that's required. Are there additional steps I need to take?

    P 1 Reply Last reply 13 Aug 2018, 18:48
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Aug 2018, 18:59 last edited by SGaist 8 Nov 2018, 18:59
      #2

      Hi,

      What version of OpenSSL are you using ?
      For what architecture ?
      With which compiler ?

      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
      • J Offline
        J Offline
        Jedd
        wrote on 13 Aug 2018, 00:27 last edited by
        #3

        1.0.2.o, March 2018
        mingw32
        Windows 10
        Qt 5.10.1

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 13 Aug 2018, 18:42 last edited by
          #4

          Might be a silly question but did you check that the build is for the correct architecture ?

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

          J 1 Reply Last reply 14 Aug 2018, 22:32
          0
          • J Jedd
            11 Aug 2018, 16:25

            I'm getting network error 301 when reading a text file from an https website. I copied ssleay32.dll and libelay32.dll alongside my exe and added CONFIG += openssl-linked into my project file. My Qt is 5.10.1, statically linked. Works fine with a http website of course.

            Most of what I read seemed to suggest that the two dlls and the openssl-linked flag would be all that's required. Are there additional steps I need to take?

            P Offline
            P Offline
            Pablo J. Rogina
            wrote on 13 Aug 2018, 18:48 last edited by
            #5

            @Jedd said in qt ssl and https:

            I'm getting network error 301

            Do you mean HTTP error 301? If so, you may want to check the reasons and how to solve it by searching the net i.e. this article may help.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jedd
              wrote on 14 Aug 2018, 22:28 last edited by
              #6

              That's very odd, since this is a Windows-only error. It does not occur with Linux or Mac.

              My code for reading the text file:

              QNetworkRequest request;
              request.setUrl(QUrl("https://www.mysite.com/file.txt"));
              QNetworkAccessManager *m_networkManager = new QNetworkAccessManager();
              QNetworkReply *reply = m_networkManager->get(request);
              
              connect(reply, SIGNAL(finished()),
                      this, SLOT(onRequestCompleted()));
              

              the error code returns 301 for Windows only, not Linux, not Mac.

                 int err = reply->error();
                 QString s2 = QString::number(err);
              

              Additionally, I recompiled 5.10.1 using thus:

              configure.bat -opensource -confirm-license -release -static -opengl desktop -platform win32-g++ -prefix "C:\Qt\5.10.1_Static" -skip webengine -openssl-linked -I C:/OpenSSL-Win32/include -L C:/OpenSSL-Win32/lib/MinGW OPENSSL_LIBS="-llibeay32 -lssleay32" -nomake tools -nomake tests -nomake examples

              And no error with this kit, as long as I have the OpenSSL eay dll files included AND I have msvcr120.dll
              (this is a real irritant, since it's not usually required for mingw32!)

              1 Reply Last reply
              0
              • S SGaist
                13 Aug 2018, 18:42

                Might be a silly question but did you check that the build is for the correct architecture ?

                J Offline
                J Offline
                Jedd
                wrote on 14 Aug 2018, 22:32 last edited by
                #7

                @SGaist

                @SGaist said in qt ssl and https:

                Might be a silly question but did you check that the build is for the correct architecture ?

                I'm not sure I understand. Windows mingw32. Everything seems fine with the exception of this ssl issue.

                P 1 Reply Last reply 14 Aug 2018, 23:24
                0
                • J Jedd
                  14 Aug 2018, 22:32

                  @SGaist

                  @SGaist said in qt ssl and https:

                  Might be a silly question but did you check that the build is for the correct architecture ?

                  I'm not sure I understand. Windows mingw32. Everything seems fine with the exception of this ssl issue.

                  P Offline
                  P Offline
                  Pablo J. Rogina
                  wrote on 14 Aug 2018, 23:24 last edited by
                  #8

                  @Jedd if the exact Qt application runs Ok under Linux/Mac but is getting HTTP status code 301 contacting the exact same server, I'd say it's a perfect case to do network traffic analysis with Wireshark. You may want to compare what the Qt application is sending and receiving both under Windows (faulty) and Linux (Ok).
                  In addition, this stack overflow question may help you.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  J 1 Reply Last reply 15 Aug 2018, 00:10
                  0
                  • P Pablo J. Rogina
                    14 Aug 2018, 23:24

                    @Jedd if the exact Qt application runs Ok under Linux/Mac but is getting HTTP status code 301 contacting the exact same server, I'd say it's a perfect case to do network traffic analysis with Wireshark. You may want to compare what the Qt application is sending and receiving both under Windows (faulty) and Linux (Ok).
                    In addition, this stack overflow question may help you.

                    J Offline
                    J Offline
                    Jedd
                    wrote on 15 Aug 2018, 00:10 last edited by Jedd
                    #9

                    @Pablo-J.-Rogina As I mentioned, the Windows error goes away with Qt recompiled statically with -ssl-linked. The only issue with this solution is the msvcr120.dll requirement, which is not a good thing. I've never required it before for a mingw32-compiled program.

                    P 1 Reply Last reply 15 Aug 2018, 15:42
                    0
                    • J Jedd
                      15 Aug 2018, 00:10

                      @Pablo-J.-Rogina As I mentioned, the Windows error goes away with Qt recompiled statically with -ssl-linked. The only issue with this solution is the msvcr120.dll requirement, which is not a good thing. I've never required it before for a mingw32-compiled program.

                      P Offline
                      P Offline
                      Pablo J. Rogina
                      wrote on 15 Aug 2018, 15:42 last edited by
                      #10

                      @Jedd said in qt ssl and https:

                      I've never required it before for a mingw32-compiled program.

                      Using the same environment as you're using now?
                      I mean, you are now using "with Qt recompiled statically with -ssl-linked"

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      J 1 Reply Last reply 16 Aug 2018, 00:58
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 15 Aug 2018, 17:39 last edited by
                        #11

                        You can use something like Dependency Walker to check where that dependency comes from.

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

                        J 1 Reply Last reply 16 Aug 2018, 02:20
                        0
                        • P Pablo J. Rogina
                          15 Aug 2018, 15:42

                          @Jedd said in qt ssl and https:

                          I've never required it before for a mingw32-compiled program.

                          Using the same environment as you're using now?
                          I mean, you are now using "with Qt recompiled statically with -ssl-linked"

                          J Offline
                          J Offline
                          Jedd
                          wrote on 16 Aug 2018, 00:58 last edited by
                          #12

                          @Pablo-J.-Rogina Yes. I've never used VS on Windows, just mingw. In fact, VS isn't even installed.

                          1 Reply Last reply
                          0
                          • S SGaist
                            15 Aug 2018, 17:39

                            You can use something like Dependency Walker to check where that dependency comes from.

                            J Offline
                            J Offline
                            Jedd
                            wrote on 16 Aug 2018, 02:20 last edited by
                            #13

                            @SGaist Thanks for that suggestion. Depends revealed the openssl I'm includiing has an msvcr dependency. I'm looking for a different solution. Pity I can't just include the openssl DLLs that Qt uses.

                            1 Reply Last reply
                            0

                            1/13

                            11 Aug 2018, 16:25

                            • Login

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