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. QSslSocket Behaviour Linux vs macOS (possibly LibreSSL incompatibilities?)
QtWS25 Last Chance

QSslSocket Behaviour Linux vs macOS (possibly LibreSSL incompatibilities?)

Scheduled Pinned Locked Moved Solved General and Desktop
47 Posts 2 Posters 12.0k 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 SGaist
    7 Mar 2018, 22:14

    What modules are you using for it currently ?

    M Offline
    M Offline
    Markus M.
    wrote on 7 Mar 2018, 22:22 last edited by
    #20

    @SGaist

    core, widgets and network. This is only for the server, the client also requires gui.

    Its just crazy, just "make clean" takes forever

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Mar 2018, 22:34 last edited by
      #21

      So qtbase is enough.

      Use out of source builds, so if you want to start from scratch you only have to nuke the build folder and the sources stay clean.

      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 7 Mar 2018, 23:41
      0
      • S SGaist
        7 Mar 2018, 22:34

        So qtbase is enough.

        Use out of source builds, so if you want to start from scratch you only have to nuke the build folder and the sources stay clean.

        M Offline
        M Offline
        Markus M.
        wrote on 7 Mar 2018, 23:41 last edited by Markus M. 3 Aug 2018, 03:54
        #22

        @SGaist edit: after hours of investigation I got it to configure/compile. I had to manually point/symlink the openssl files located in /usr/local/lib and /usr/local/include, respectively, to the directory where openssl actually sits.

        As it seems configure bails out for openssl versions north of 1.1.0. For some reason (no idea how this came about) I had openssl 1.1.1-pre-something installed.

        Follow up: the private Key is indeed set; however, something is wrong with it because Qt marks it "isNull". That is, I can qDebug it and at first glance it looks fine. Same on Linux.

        Follow up 2: I used the code as posted in
        https://forum.qt.io/topic/45728/generating-cert-key-during-run-time-for-qsslsocket/7

        Again - as @Pradeep-P-N reported, the code crashes in the final step (setPrivateKey); that is, the privateKey is null. The said is true on macOS using openssl 1.0.2n

        Follow up 3: Under Linux, a valid key is indeed created. However, the key does not seem to be relayed to the server. Keep digging...

        Follow up 4: Have not managed to create a key via openssl that could be loaded from disk - neither on Linux nor on the Mac. Not sure what's going on, the private Key just is always null (have tried various formats...). For now solely the code as posted in the linked thread above works under Linux.

        For now I suspect main the problem has to do with the linked openssl version on the Mac: Building gives lots of warnings: object file (libcrypto.a) ws built for newer OSX version (10.13) than being linked (10.10).

        If I get that correctly this means the openssl lib used to generate the keys was built on 10.13 whereas Qt's version was build on 10.10?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 8 Mar 2018, 12:51 last edited by
          #23

          OpenSSL 1.1 broke API and ABI compatibility with the 1.0 series.

          Up to Qt 5.10, only 1.0 was supported. Since 5.10, you can build the 1.1 backend but Qt is still delivered with 1.0 currently.

          IIRC, Qt is built with the latest version of Xcode at the time and has a run target of "Current release" -3 (the same number of versions that Apple still supports) following Apple's policy of "build with the latest version of Xcode".

          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 8 Mar 2018, 17:52
          0
          • S SGaist
            8 Mar 2018, 12:51

            OpenSSL 1.1 broke API and ABI compatibility with the 1.0 series.

            Up to Qt 5.10, only 1.0 was supported. Since 5.10, you can build the 1.1 backend but Qt is still delivered with 1.0 currently.

            IIRC, Qt is built with the latest version of Xcode at the time and has a run target of "Current release" -3 (the same number of versions that Apple still supports) following Apple's policy of "build with the latest version of Xcode".

            M Offline
            M Offline
            Markus M.
            wrote on 8 Mar 2018, 17:52 last edited by Markus M. 3 Aug 2018, 18:05
            #24

            @SGaist Hi. Happy to be able to report that part of the experienced issues are solved using Qt compiled from source (linked against OpenSSL 1.0.2n). More specifically, the server part now accepts connections, the socket errors (20, 21) are gone.
            The code segment posted in mentioned thread above now works on the Mac as well, i.e. i can generate private keys in code now.

            That said, the QSslKey loading problem still exists. In particular, its still fails to set a private key loaded from file. I wonder whats the root cause - to me it seems like its a bug in Qt. All the samples I found online do not seem to work...

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 8 Mar 2018, 20:48 last edited by
              #25

              Would it possible for you to provide a small client/server project(s) that allows to test that behaviour ?

              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 8 Mar 2018, 21:02
              0
              • S SGaist
                8 Mar 2018, 20:48

                Would it possible for you to provide a small client/server project(s) that allows to test that behaviour ?

                M Offline
                M Offline
                Markus M.
                wrote on 8 Mar 2018, 21:02 last edited by
                #26

                @SGaist I could provide the client code - which should be ok for testing this?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 8 Mar 2018, 21:31 last edited by
                  #27

                  In the absolute, having also a test server would be nice (doesn't need to be C++ for that part) as it would allow to be sure that a failing connection can properly be made.

                  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 8 Mar 2018, 21:37
                  0
                  • S SGaist
                    8 Mar 2018, 21:31

                    In the absolute, having also a test server would be nice (doesn't need to be C++ for that part) as it would allow to be sure that a failing connection can properly be made.

                    M Offline
                    M Offline
                    Markus M.
                    wrote on 8 Mar 2018, 21:37 last edited by Markus M. 3 Sept 2018, 02:59
                    #28

                    @SGaist I understand; still its kind of difficult to just give out the sources since some of the tech used there (unrelated to connecting) is under heavy confidentiality requirements.

                    That said, a server you could connect to is available via DynDNS (edit: tested - working)

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 8 Mar 2018, 21:57 last edited by
                      #29

                      No worries, that's not what I was asking you to do at all !

                      Just some dummy test server using the custom certificate so that the communication can be tested/established with the test client.

                      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 8 Mar 2018, 22:40
                      0
                      • S SGaist
                        8 Mar 2018, 21:57

                        No worries, that's not what I was asking you to do at all !

                        Just some dummy test server using the custom certificate so that the communication can be tested/established with the test client.

                        M Offline
                        M Offline
                        Markus M.
                        wrote on 8 Mar 2018, 22:40 last edited by Markus M. 3 Sept 2018, 01:04
                        #30

                        @SGaist Here we go: https://github.com/markusmeyerhofer/SimpleServer

                        Just a heads-up: this is a quickly distilled ssl server; it should work but its certainly not tested exhaustively.

                        The client: https://github.com/markusmeyerhofer/QtSSLClient

                        I created a small project creating certs and keys (again, using the sample provided in the mentioned thread above) and writing those to disk.
                        I imported a key generated this way (recall: this key is accepted as valid by QSslKey) into a resource file and load that file in my SSL client - where the exact same key is rejected ("isNull").

                        Visual inspection (qDebugging out the loaded file) suggests an actually valid key file. As it stands it looks like something happens during loading the key file. Not sure what I'm doing wrong...
                        (Hint: the respective code segment is in "citcpconnection.cpp" lines 27ff, see Github Repo QtSSLClient as given above)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 11 Mar 2018, 20:36 last edited by
                          #31

                          After some testing, the certificate itself is good. What poses problem currently is the key. Poking at the sources and searching a bit, the key you are generating is a PKCS8 type of key which doesn't seem to be handled currently. PKCS1 keys on the other should be good.

                          I didn't had time to go through OpenSSL to find how to generate such a key from the API however on the command line it seems to be as simple as: openssl rsa -in server.key -out server_new.key.

                          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

                          M 1 Reply Last reply 11 Mar 2018, 20:41
                          0
                          • S SGaist
                            11 Mar 2018, 20:36

                            After some testing, the certificate itself is good. What poses problem currently is the key. Poking at the sources and searching a bit, the key you are generating is a PKCS8 type of key which doesn't seem to be handled currently. PKCS1 keys on the other should be good.

                            I didn't had time to go through OpenSSL to find how to generate such a key from the API however on the command line it seems to be as simple as: openssl rsa -in server.key -out server_new.key.

                            Hope it helps.

                            M Offline
                            M Offline
                            Markus M.
                            wrote on 11 Mar 2018, 20:41 last edited by Markus M. 3 Nov 2018, 20:48
                            #32

                            @SGaist Thx for the heads - up. What still puzzles me is: how is it that the key generated in code (its in the client code posted) is accepted when fed into QSslKey directly; when storing the key as is and subsequently loading from file it isn't.

                            Anyway, its kinda tedious - there are so many formats and how tos out there I kinda lost oversight. What I need is basically:

                            1 - A certificate (self-signed) acting as CA certificate.
                            2 - A server and a client key + certs, signed by the CA cert as created in 1. I did that, but, as you know, the key isn't accepted.

                            There are other issues I don't quite understand: e.g. the key, even though set in the client, does not seem to appear on the server; meaning it isn't used. Similarly, setting the peer host name on the client, getting peerHostName on the server happens to be empty. Not sure why...

                            The connection still is encrypted, but host identification is defunct as of now, opening a hole

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 11 Mar 2018, 21:10 last edited by
                              #33

                              Looking for something else, I stumble on this bug of Curl which I wonder if it relates to the problem at end.

                              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 11 Mar 2018, 21:13
                              0
                              • S SGaist
                                11 Mar 2018, 21:10

                                Looking for something else, I stumble on this bug of Curl which I wonder if it relates to the problem at end.

                                M Offline
                                M Offline
                                Markus M.
                                wrote on 11 Mar 2018, 21:13 last edited by Markus M. 3 Nov 2018, 21:15
                                #34

                                @SGaist said in QSslSocket Behaviour Linux vs macOS (possibly LibreSSL incompatibilities?):

                                bug of Curl

                                I doubt it: the bug seems to address Yosemite; my issues are for one: on High Sierra and for two: consistent over various platforms (OpenSuSE, Ubuntu; Mac).

                                Besides - why curl? I am not knowingly using curl for that project. Is it somehow used by Qt under the hood?

                                M 1 Reply Last reply 22 Dec 2018, 00:44
                                0
                                • M Markus M.
                                  11 Mar 2018, 21:13

                                  @SGaist said in QSslSocket Behaviour Linux vs macOS (possibly LibreSSL incompatibilities?):

                                  bug of Curl

                                  I doubt it: the bug seems to address Yosemite; my issues are for one: on High Sierra and for two: consistent over various platforms (OpenSuSE, Ubuntu; Mac).

                                  Besides - why curl? I am not knowingly using curl for that project. Is it somehow used by Qt under the hood?

                                  M Offline
                                  M Offline
                                  Markus M.
                                  wrote on 22 Dec 2018, 00:44 last edited by
                                  #35

                                  Hello.. as a follow up: I am not aware of the changes that took place under the hood in Qt 5.12.

                                  However, the issues as described apparently are fixed now; i.e. I am now using Qt 5.12.0 as provided/updated using the Qt Maintenance Tool.

                                  In more detail: I had to use the custom compiled Qt 5.10.0 in order to be able to connect to my QSsl - based development server under macOS.
                                  With the latest update to Qt 5.12.0 everything works as intended out of the box, no custom Qt/SSL compilation required any more.

                                  Thx for fixing this!

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 22 Dec 2018, 18:54 last edited by
                                    #36

                                    Glad it's working now and thanks for the feedback !

                                    Additonal note, I never wrote that this was a curl problem or bug that was affecting your application. Only that the bug report I found could give some additonal clues to look into to fix your problem.

                                    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 Dec 2018, 19:08
                                    0
                                    • S SGaist
                                      22 Dec 2018, 18:54

                                      Glad it's working now and thanks for the feedback !

                                      Additonal note, I never wrote that this was a curl problem or bug that was affecting your application. Only that the bug report I found could give some additonal clues to look into to fix your problem.

                                      M Offline
                                      M Offline
                                      Markus M.
                                      wrote on 22 Dec 2018, 19:08 last edited by Markus M.
                                      #37

                                      @SGaist Actually the post above may have been a bit premature. Not sure what is going on: I updated 2 machines to Qt 5.12.0.

                                      On my workstation, it is working as intended and described in the previous post.

                                      Since I assumed the issues have been fixed I also updated my Macbook only to find out the failed handshake still occurs.

                                      Currently I am in the process of investigating what is going on - mentioned computers installations are very similar. All I know for now is that the handshake failures occur only on one computer with standard Qt installation.
                                      I suspect the cause is somehow tied to libssl.a/libcrypto.a, perhaps different ssl version or something like that.

                                      I'll keep you advised if I find out what's going on

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 22 Dec 2018, 19:39 last edited by
                                        #38

                                        The one problem I can see is that OpenSSL is not used on macOS since a few Qt versions. Qt use the SecureTransport framework from macOS. You can still use OpenSSL though but you have to build Qt yourself for that as well as get a recent version of OpenSSL.

                                        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 Dec 2018, 19:48
                                        0
                                        • S SGaist
                                          22 Dec 2018, 19:39

                                          The one problem I can see is that OpenSSL is not used on macOS since a few Qt versions. Qt use the SecureTransport framework from macOS. You can still use OpenSSL though but you have to build Qt yourself for that as well as get a recent version of OpenSSL.

                                          M Offline
                                          M Offline
                                          Markus M.
                                          wrote on 22 Dec 2018, 19:48 last edited by Markus M.
                                          #39

                                          @SGaist I know - I did compile Qt with OpenSSL 1.0.2o a couple of months ago (Qt 5.10.0).
                                          Unfortunately later versions Qt failed to compile using this config - never figured out why; for the lack of time I just went ahead using mentioned custom compiled version.

                                          Yesterday I randomly checked if my server compiles/works using 5.12.0 - and to my surprise it did (on my workstation).
                                          It still doesn't on the Macbook what puzzles me...

                                          otool -L indicates everything is similar. The binary compiled on the workstation also does not work on the notebook - so clearly some dynamically linked library causing this. If only I knew which one

                                          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