Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Creating a SSL socket in Qt for Android
Forum Updated to NodeBB v4.3 + New Features

Creating a SSL socket in Qt for Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
15 Posts 2 Posters 1.2k Views 1 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.
  • D diego-qt
    6 Nov 2023, 15:28

    @jsulm yes I have found it in /opt/Qt5.15/include/QtSerialPort
    And yes I went to Projects > Build > CMake > Build directory and entered a new directory.

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 7 Nov 2023, 06:36 last edited by
    #6

    @diego-qt Strange thing is that compiler does not complain about QSslSocket include. Check the QSslSocket header file to see whether it declares the QSslSocket class.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    D 1 Reply Last reply 23 Apr 2024, 10:09
    0
    • J jsulm
      7 Nov 2023, 06:36

      @diego-qt Strange thing is that compiler does not complain about QSslSocket include. Check the QSslSocket header file to see whether it declares the QSslSocket class.

      D Offline
      D Offline
      diego-qt
      wrote on 23 Apr 2024, 10:09 last edited by
      #7

      @jsulm hi, I'm back after some time, still with the QSslSocket problem, any help is much appreciated

      I looked into the QSslSocket header file and it contains only this:

      #include "qsslsocket.h"
      

      And the so called qsslsocket.h does exist

      J 1 Reply Last reply 23 Apr 2024, 10:36
      0
      • D diego-qt
        23 Apr 2024, 10:09

        @jsulm hi, I'm back after some time, still with the QSslSocket problem, any help is much appreciated

        I looked into the QSslSocket header file and it contains only this:

        #include "qsslsocket.h"
        

        And the so called qsslsocket.h does exist

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 23 Apr 2024, 10:36 last edited by
        #8

        @diego-qt said in Creating a SSL socket in Qt for Android:

        And the so called qsslsocket.h does exist

        And does it define the QSslSocket class?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply 23 Apr 2024, 12:51
        0
        • J jsulm
          23 Apr 2024, 10:36

          @diego-qt said in Creating a SSL socket in Qt for Android:

          And the so called qsslsocket.h does exist

          And does it define the QSslSocket class?

          D Offline
          D Offline
          diego-qt
          wrote on 23 Apr 2024, 12:51 last edited by
          #9

          @jsulm yes indeed, the class definition starts with

          class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
          {
          
          D 1 Reply Last reply 23 Apr 2024, 12:54
          0
          • D diego-qt
            23 Apr 2024, 12:51

            @jsulm yes indeed, the class definition starts with

            class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
            {
            
            D Offline
            D Offline
            diego-qt
            wrote on 23 Apr 2024, 12:54 last edited by
            #10

            I see that my problem is Android-related, because when I try to compile the same project with my Desktop kit, it works. QSslSocket is recognized.

            J 1 Reply Last reply 23 Apr 2024, 13:20
            0
            • D diego-qt
              23 Apr 2024, 12:54

              I see that my problem is Android-related, because when I try to compile the same project with my Desktop kit, it works. QSslSocket is recognized.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 23 Apr 2024, 13:20 last edited by
              #11

              @diego-qt Could be that QSslSocket is not available on Android. Look for #ifdef/#ifndef in the header file.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              D 1 Reply Last reply 23 Apr 2024, 14:40
              0
              • J jsulm
                23 Apr 2024, 13:20

                @diego-qt Could be that QSslSocket is not available on Android. Look for #ifdef/#ifndef in the header file.

                D Offline
                D Offline
                diego-qt
                wrote on 23 Apr 2024, 14:40 last edited by
                #12

                @jsulm I see something interesting now that you mention it.

                #ifndef QT_NO_SSL
                

                When I activate the Android kit, the code under this #ifndef directive is grayed out (so most of the code, actually). I'm guessing I have to activate it, but putting

                #ifndef QT_NO_SSL
                #define QT_NO_SSL
                #endif
                

                in my header file before calling #include <QSslSocket> does not do the trick. How could it be done ?

                By the way, I see that when I activate the Desktop kit, the definition of QSslSocket in qsslsocket.h is not grayed out.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  diego-qt
                  wrote on 23 Apr 2024, 15:21 last edited by
                  #13

                  These bug reports suggest that I'm not the only one with this problem:
                  https://bugreports.qt.io/browse/QTBUG-88238
                  https://bugreports.qt.io/browse/QTBUG-65531

                  But there haven't been answers on the issues.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    diego-qt
                    wrote on 24 Apr 2024, 10:42 last edited by
                    #14

                    @jsulm I found that the qsslsocket.h file starts with:

                    #include <QtNetwork/qtnetworkglobal.h>
                    #include <QtCore/qlist.h>
                    #include <QtCore/qregexp.h>
                    #include <QtCore/qvector.h>
                    

                    And the QtNetwork/qtnetworkglobal.h file starts with:

                    #include <QtCore/qglobal.h>
                    #include <QtNetwork/qtnetwork-config.h>
                    

                    And finally, in the QtNetwork/qtnetwork-config.h file I found (among other defines):

                    #define QT_NO_SSL
                    

                    I have the impression then that QSslSocket can't be defined when in Android kit. However, when I activate the Desktop kit, the #define QT_NO_SSL is not found in the last file I mentioned, that's why my project compiles with this kit.
                    I don't understand why this happens. I might need to rerun a configuration file but I don't know what exactly to do.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      diego-qt
                      wrote on 2 May 2024, 16:25 last edited by
                      #15

                      Hello @jsulm I have looked deeper into my problem and found some things. Could you help me by confirming as far as you can? Or recommend someone that may know the answer?

                      I found a new documentation page I hadn't read: https://doc.qt.io/qt-5/ssl.html#enabling-and-disabling-ssl-support
                      When I launched the configure program with the openssl-linked option, I finally got a QtNetwork/qtnetwork-config.h file without the definition that caused trouble (see above). However, when I tried to save the new qmake version and its Android kit, I get an error saying that the Android Clang compiler "can't produce code for the Qt version "Qt 5.15.13 (Qt-5.15.13)" (x86-linux-generic-elf-64bit)."

                      What I understand is that I didn't activate the target for cross-compilation in the initial configuration step.
                      So I went back and launched this

                      OPENSSL_LIBS='-L~/android-sdk/android_openssl/ssl_1.1/arm64-v8a/include -lssl -lcrypto' \
                      ~/qt5/configure -openssl-linked -prefix /opt/Qt5.15 -xplatform android-clang \
                      -disable-rpath -nomake tests -nomake examples -android-ndk ~/android-sdk/ndk/21.3.6528147 \
                      -android-sdk ~/android-sdk -no-warnings-are-errors -opensource -confirm-license
                      

                      But I got the following error:

                      ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.
                      
                      Check config.log for details.
                      

                      Please note that when I launch the mentioned command without -xplatform android-clang, it seems to work and I am asked to launch gmake. So for the time being I have found myself in an incompatibility of installing an SSL-supported Qt and cross-compiling for Android.

                      Regarding the config log file that the error indicates me, I don't know what exactly to look at.
                      What I find interesting is that at some point there is this SSL-related error (with the -xplatform option):

                      + cd /home/diego/qt-build/config.tests/openssl && MAKEFLAGS= /usr/bin/gmake clean && MAKEFLAGS= /usr/bin/gmake
                      > rm -rf /home/diego/qt-build/config.tests/openssl/android-build
                      > rm -f main.o
                      > rm -f *~ core *.core
                      > /home/diego/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -c -target aarch64-linux-android21 -fno-limit-debug-info -fPIC -fstack-protector-strong -DANDROID -O2 -fPIC  -I. -I/home/diego/qt5/qtbase/mkspecs/android-clang -o main.o main.cpp
                      > main.cpp:2:10: fatal error: 'openssl/ssl.h' file not found
                      > #include <openssl/ssl.h>
                      >          ^~~~~~~~~~~~~~~
                      > 1 error generated.
                      > gmake: *** [Makefile:193 : main.o] Erreur 1
                      

                      The weird thing is that without the -xplatform option, I don't see this error, and yet the two command lines are otherwise the same one.

                      Apart from that, there are many other errors, but as I said I don't know exactly what to look at.

                      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