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 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?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #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 last edited by
        #3

        1.0.2.o, March 2018
        mingw32
        Windows 10
        Qt 5.10.1

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          0
          • J Jedd

            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?

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on 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 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
              • SGaistS SGaist

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

                J Offline
                J Offline
                Jedd
                wrote on 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.

                Pablo J. RoginaP 1 Reply Last reply
                0
                • J Jedd

                  @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.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on 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
                  0
                  • Pablo J. RoginaP Pablo J. Rogina

                    @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 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.

                    Pablo J. RoginaP 1 Reply Last reply
                    0
                    • J Jedd

                      @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.

                      Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on 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
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 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
                        0
                        • Pablo J. RoginaP Pablo J. Rogina

                          @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 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
                          • SGaistS SGaist

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

                            J Offline
                            J Offline
                            Jedd
                            wrote on 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

                            • Login

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