Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Android: Downloading from HTTPS does not work



  • Qt 5.12 LTS
    Android NDK r14
    Android SDK r25.2.5 for 28.0.2

    Qt Creator 4.8.0
    Based on Qt 5.12.0 (Clang 10.0 (Apple), 64 bit)
    Built on Dec 3 2018 13:07:25
    From revision d51ddbb8f0

    HTTPS support for Android does not work. It should also be noted that HTTPS works fine on iOS devices.

    On Android 6-8 devices, it causes an app attempting to download a file from an HTTPS url to signal “done” and download nothing.

    Error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

    D appname: FileDownLoader::RequestFileFromServer..from:  "https://www.companyname.biz/resources/DBs/"
    
    E linker  : library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/com.companyname.appname-nV0MXGxGe9soTVz8ADNyYw==/lib/arm/libQt5Core.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.companyname.appname-nV0MXGxGe9soTVz8ADNyYw==/lib/arm:/data/app/com.companyname.appname-nV0MXGxGe9soTVz8ADNyYw==/base.apk!/lib/armeabi-v7a", permitted_paths="/data:/mnt/expand:/data/data/com.companyname.appname"]
    
    W appname: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
    

    HTTP support for Android 6,7,8 works fine. (I have only tested on a device with 8) That is to say..the same exact code accessing a HTTP VS HTTPS url downloads as expected when tested on Android 8.

    In searching for a solution on-line, it appears to be that Android OSes pre-6 all shipped or included SSL support. While that is no longer the case with 6 and up.

    Where do I find pre-compiled libraries that support SSL and HTTPS or whatever else is required to make Qt work on Android 6,7,&8 ?

    Apparently this has already been “bugged” but after 3 months still unresolved:
    https://bugreports.qt.io/browse/QTBUG-71391

    Other than NOT using HTTPS for Android and using HTTP instead..is there a solution?


  • Lifetime Qt Champion

    Hi,

    The procedure is explained in the Android dedicated page in Qt's documentation.



  • @SGaist

    Thanks. Yes I saw that page.

    @QtCorporation

    I get that I could do that, but what am I paying my monthly $99 license fee for???

    Shouldn't Qt include basic HTTPS functionality and support in their products if they market them as Cross Platform?

    Why would Qt make this the responsibility of each and every Android developer using their product..when they could do it once and make sure it was done correctly????

    Rant finished.


  • Qt Champions 2019

    @PSI_lbc You should read the link posted by @SGaist
    "The Qt installation package comes with OpenSSL support but the OpenSSL libraries are not part of the package due to legal restrictions in some countries."
    Also, if you have a commercial license and want to talk to Qt Company you should contact them directly instead of doing it here. This is a forum where volunteers are helping.



  • This is clearly about the worst possible way to do this.

    Most (for all practical purposes - all) applications that use any kind of external WEB/REST/Websockets API's will use https .

    In stead of forcing each and every developer to manually add openssl to the build, creating friction with and frustration about Qt in the process, - why don't you just provide a button in the build or project settings where we can enable openssl for that build / project?

    That will solve the legal problem, and save quite a few wasted hours for developers.

    I was planning to showcase a Qt/QML application for Linux Desktop and Android tomorrow - but I'm not wasting a Sunday on this BS. Now I will go for a walk with my dogs, and just forget about the Android demo. Linux Desktop will do. If someone in the audience asks why I don't have an Android build, I'll just admit it was too much work.


  • Qt Champions 2019

    @jgaa You're welcome to submit improvement ideas on the Qt developers mailing list or Qt bug tracker.


Log in to reply