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. OpenSSL for android and Qt 5.12.4
Forum Updated to NodeBB v4.3 + New Features

OpenSSL for android and Qt 5.12.4

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 3.2k 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.
  • W Offline
    W Offline
    Wiru
    wrote on 3 Jul 2019, 13:22 last edited by Wiru 7 Mar 2019, 14:35
    #1

    Just to clear up some stuff to see if I understand right.
    Based on Qt-5-12-4-released-support-openssl-1-1-1 we now have to use the openssl 1.1.1 version and 1.0.2 won't work.

    There is some "tutorial" android-openssl-support on how to build, I put the quotes because it's outdated, if I'm not wrong. NDK 18+ has stand-alone toolchains which is not supported by the script, additionally Configure command is for openssl 1.0.2

    I managed to find a guide on how to build openssl 1.1.1 with NDK 18+ (in case anyone else will need), and after the build there is more than just the standard libcrypto.so and libssl.so, the new ones are libcrypto.a and libssl.a, since that are archive libraries, are they also required for Qt to work, or are the normal so files enough?

    If anyone could clarify what exactly is needed, or if I'm mistaken in something.

    It seems trivial, but for someone like me who only used the libs because they need to be there it seems like a huge jump from 1.0.2 to 1.1.1

    EDIT:
    I built 1.0.2 to remind myself how the build folder looks like, it also has the .a files, so I assume they are not required at all for Qt, just the .so?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deleted372
      wrote on 3 Jul 2019, 15:17 last edited by
      #2

      I agree with you... the transition to OpenSSL 1.1.1 is not easy at all. The guide you found is OK.

      You need Linux or Mac to compile the OpenSSL libraries and be ready to use the Terminal.

      This is the procedure I used on a mac, but should work also on Linux... on Windows forget it...

      Open the Documents folder and create a new folder, call it openSSL

      Download openssl-1.1.1c : https://www.openssl.org/source/openssl-1.1.1c.tar.gz
      Download NDK r19c : https://developer.android.com/ndk/downloads/older_releases.html

      extract everything in the folder "openSSL" and create a file named "compileScript.sh", open it and paste the following code

      #!/bin/bash
      SCRIPTPATH=$(pwd)
      OPENSSL_DIR=$SCRIPTPATH/openssl-1.1.1c
      
      export ANDROID_NDK_HOME=$SCRIPTPATH/android-ndk-r19c
      PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/:$PATH
      
      # Can be android-arm, android-arm64, android-x86, android-x86 etc
      architecture=android-arm
      #architecture=android-arm64
      #architecture=android-x86
      #architecture=android-x86_64
      
      #set clang compiler
      CC=clang
      cd $OPENSSL_DIR
      ./Configure $architecture -D__ANDROID_API__=28
      make
      
      OUTPUT_INCLUDE=$SCRIPTPATH/output/include
      OUTPUT_LIB=$SCRIPTPATH/output/lib/$architecture
      mkdir -p $OUTPUT_INCLUDE
      mkdir -p $OUTPUT_LIB
      cp -RL include/openssl $OUTPUT_INCLUDE
      cp libcrypto.so $OUTPUT_LIB
      cp libssl.so $OUTPUT_LIB
      

      Now open a terminal and run the following commands

      cd ~/Documents/openSSL
      chmod +x compileScript.sh
      ./compileScript.sh
      

      If everything is Ok, after a couple of minutes you will find your .so files in the output folder... libssl.so and libcrypto.so is all you need.

      Once they are compiled, you can copy paste in the resources of your project. This is what I have in my .pro file:

      
      equals(ANDROID_TARGET_ARCH, arm64-v8a) {
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-arm64/libcrypto.so
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-arm64/libssl.so
      }
      else: equals(ANDROID_TARGET_ARCH, armeabi-v7a) {
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-arm/libcrypto.so
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-arm/libssl.so
      }
      else: equals(ANDROID_TARGET_ARCH, x86)  {
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-x86/libcrypto.so
          ANDROID_EXTRA_LIBS += $$PWD/../libs/lib/android-x86/libssl.so
      }
      
      1 Reply Last reply
      1
      • W Offline
        W Offline
        Wiru
        wrote on 4 Jul 2019, 05:54 last edited by Wiru 7 Apr 2019, 05:59
        #3

        Your way should work too, I finished all the builds with the guide I found so didn't try yours yet. Only difference is I also put the shared flag for config, only because the old Qt guide did the same ( so I assume it needs it here as well)

        Just one thing to point out (at least in my case) the libcrypto.so and libssl.so are links to the actual libs called libcrypto.so.1.1 and libssl.so.1.1, so thats what you need in your project.

        I was confused about the .a files because the guide mentioned to copy those too, but I assume it's only in case for Android studio.
        I confirmed the libs to work after testing on some https content.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          deleted372
          wrote on 5 Jul 2019, 08:40 last edited by
          #4

          There are some updates from Qt:
          Here you find OpenSSL prebuilt libraries
          https://github.com/KDAB/android_openssl

          Here you find updated instructions:
          https://doc-snapshots.qt.io/qt5-5.12/android-openssl-support.html

          1 Reply Last reply
          1
          • F Offline
            F Offline
            fXs.
            wrote on 18 Jul 2019, 10:54 last edited by fXs.
            #5

            Qt 5.12.4
            NDK 19c
            QT creator 4.9.2
            Windows 10
            Developing Android 4.4.4 apk.

            I swicth to Utuntu, downloaded NDK for linux run https://github.com/KDAB/android_openssl . After that everythings goes well. It created libcrypto.so and libssl.so files. I put in my project, and i always get eror like :

            .....
            qt.network.ssl: QSslSocket: cannot resolve X509_get_version
            qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version_num
            qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version
            qt.network.ssl: Incompatible version of OpenSSL
            

            Also then i build apk file i see problem then is loading libcrypto.so file:

            .dynamic section for "libcrypto.so" is not at the expected address (wrong library or version mismatch?)
            

            I try to use QSslSocket::sslLibraryBuildVersionString() and it tel me that it is version 1.1.1b. I compiled .so files from OpenSsl 1.1.1c. Why it show another version?

            After that i try to compile .so files from version 1.1.1b. But i still get the same erorr.

            Im working with this erorr about a week, and still nothing....

            W 1 Reply Last reply 19 Jul 2019, 01:50
            0
            • F fXs.
              18 Jul 2019, 10:54

              Qt 5.12.4
              NDK 19c
              QT creator 4.9.2
              Windows 10
              Developing Android 4.4.4 apk.

              I swicth to Utuntu, downloaded NDK for linux run https://github.com/KDAB/android_openssl . After that everythings goes well. It created libcrypto.so and libssl.so files. I put in my project, and i always get eror like :

              .....
              qt.network.ssl: QSslSocket: cannot resolve X509_get_version
              qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version_num
              qt.network.ssl: QSslSocket: cannot resolve OpenSSL_version
              qt.network.ssl: Incompatible version of OpenSSL
              

              Also then i build apk file i see problem then is loading libcrypto.so file:

              .dynamic section for "libcrypto.so" is not at the expected address (wrong library or version mismatch?)
              

              I try to use QSslSocket::sslLibraryBuildVersionString() and it tel me that it is version 1.1.1b. I compiled .so files from OpenSsl 1.1.1c. Why it show another version?

              After that i try to compile .so files from version 1.1.1b. But i still get the same erorr.

              Im working with this erorr about a week, and still nothing....

              W Offline
              W Offline
              Wiru
              wrote on 19 Jul 2019, 01:50 last edited by Wiru
              #6

              @fXs. Openssl 1.1.1 doesn't work with android 4.4, you need openssl 1.0.2 and with that Qt 5.12.3.

              1 Reply Last reply
              1

              • Login

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