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. Problem when using OpenSSL in the phone

Problem when using OpenSSL in the phone

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 4 Posters 1.5k 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.
  • S Offline
    S Offline
    sfaei_Ahmed
    wrote on last edited by
    #1

    Hello, I have built a project that uses a qt network and works without problems in the desktop and when I convert it to Android, it also works, but if I click on the button that sends the data to the server, this error occurs and no data is sent.IMG_0496.jpeg IMG_0495.jpeg

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

      Hi and welcome to devnet,

      Did you include the OpenSSL libraries in your apk ?

      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
      • S sfaei_Ahmed

        Hello, I have built a project that uses a qt network and works without problems in the desktop and when I convert it to Android, it also works, but if I click on the button that sends the data to the server, this error occurs and no data is sent.IMG_0496.jpeg IMG_0495.jpeg

        Ronel_qtmasterR Offline
        Ronel_qtmasterR Offline
        Ronel_qtmaster
        wrote on last edited by
        #3

        @sfaei_Ahmed Just add android openssl libraries to your project.
        here is the guide https://github.com/KDAB/android_openssl
        I hope that it helps

        M 1 Reply Last reply
        0
        • S Offline
          S Offline
          sfaei_Ahmed
          wrote on last edited by sfaei_Ahmed
          #4

          I included it inside the cmakelist.txt file, but I don't know how to include it in the apk file.Capture.PNG

          Ronel_qtmasterR 1 Reply Last reply
          0
          • S sfaei_Ahmed

            I included it inside the cmakelist.txt file, but I don't know how to include it in the apk file.Capture.PNG

            Ronel_qtmasterR Offline
            Ronel_qtmasterR Offline
            Ronel_qtmaster
            wrote on last edited by
            #5

            @sfaei_Ahmed first of all you have wrongly included it in cmakelist. second of all i already gave you the solution in the link above. There are guidelines for including openssl libs in cmake projects. Just take your time and read carefully.

            S 1 Reply Last reply
            0
            • Ronel_qtmasterR Ronel_qtmaster

              @sfaei_Ahmed first of all you have wrongly included it in cmakelist. second of all i already gave you the solution in the link above. There are guidelines for including openssl libs in cmake projects. Just take your time and read carefully.

              S Offline
              S Offline
              sfaei_Ahmed
              wrote on last edited by
              #6

              @Ronel_qtmaster I tried, but the problem is not solved. Please, if there are any projects or examples in which it is used, send it to me.

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

                What exactly do you have now ?
                Did you get any error message on build ?
                Did you inspect the content of the APK ?

                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
                • Ronel_qtmasterR Ronel_qtmaster

                  @sfaei_Ahmed Just add android openssl libraries to your project.
                  here is the guide https://github.com/KDAB/android_openssl
                  I hope that it helps

                  M Offline
                  M Offline
                  MarcoDC
                  wrote on last edited by MarcoDC
                  #8

                  @Ronel_qtmaster I recently had the same problem using Qt6.9:

                  E/linker  (21919): library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/com.company.app--EodNGlgEtHINhQ6rIRNedQ==/lib/arm64/libQt6Core_arm64-v8a.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.company.app--EodNGlgEtHINhQ6rIRNedQ==/lib/arm64:/data/app/com.company.app--EodNGlgEtHINhQ6rIRNedQ==/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/com.company.app"]
                  W/qt.tlsbackend.ossl(21919): Failed to load libssl/libcrypto.
                  W/AudioCapabilities(21919): Unsupported mime audio/ac4
                  W/AudioCapabilities(21919): Unsupported mime audio/x-ima
                  W/qt.network.ssl(21919): No functional TLS backend was found
                  W/qt.network.ssl(21919): No TLS backend is available
                  ...
                  

                  and stumbled across your posted Link: https://github.com/KDAB/android_openssl
                  (I also think the same information are present in the official Qt doc: https://doc.qt.io/qt-6/android-openssl-support.html)
                  However I either used the command add_android_openssl_libraries(${PROJECT_NAME}) wrong or did forget something because I get an error when running CMake that this is not a known command:

                  CMake Error at CMakeLists.txt:279 (add_android_openssl_libraries):
                  [cmake]   Unknown CMake command "add_android_openssl_libraries".
                  

                  I also tried to add the extra libraries as mentioned

                  set_target_properties(<target_name> PROPERTIES
                  QT_ANDROID_EXTRA_LIBS "<path_to_libs_dir>/libcrypto_3.so" "<path_to_libs_dir>/libssl_3.so"
                  )

                  like

                  set_target_properties(${PROJECT_NAME} PROPERTIES
                      QT_ANDROID_EXTRA_LIBS
                      "${SSL_ROOT_PATH}/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libcrypto_3.so"
                      "${SSL_ROOT_PATH}/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libssl_3.so"
                  )
                  

                  but this only led to

                  CMake Error at CMakeLists.txt:274 (set_target_properties):
                  [cmake]   set_target_properties called with incorrect number of arguments.
                  

                  when trying to run it.

                  However this post https://forum.qt.io/topic/160405/cmake-equivalent-for-qmake-s-android_extra_libs/3 made me aware that

                  The values in QT_ANDROID_EXTRA_LIBS need to be separated by a semicolon.

                  and also without a newline in between which finally made me come up with

                  # Android for TLS backend
                  include(${ANDROID_SDK_ROOT}/android_openssl/CMakeLists.txt) # this sets OPENSSL_ROOT_DIR and ANDROID_EXTRA_LIBS however I seem to need set *QT_*ANDROID_EXTRA_LIBS
                  
                  set_target_properties(${PROJECT_NAME} PROPERTIES
                      QT_ANDROID_EXTRA_LIBS
                      "${SSL_ROOT_PATH}/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libcrypto_3.so;${SSL_ROOT_PATH}/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libssl_3.so"
                  )
                  

                  or even just

                  # Android for TLS backend
                  set_target_properties(${PROJECT_NAME} PROPERTIES
                      QT_ANDROID_EXTRA_LIBS
                      "${ANDROID_SDK_ROOT}/android_openssl/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libcrypto_3.so;${ANDROID_SDK_ROOT}/android_openssl/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libssl_3.so"
                  )
                  

                  Is this a bug in Qt/QtCreator or just an error in the documentation? Where could I report this?

                  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