Android 6.0 Application crashes when I use TIdHTTP for HTTPS calls

843 Views Asked by At

I'm using Delphi XE8 with Indy 10 for Android application development. I have used the TIdHTTP component for HTTP/S service calls.

It works fine in Android 5 and earlier versions, but the same is not working in Android 6.0 (when I try to access HTTPS protocols).

I tried with TIdSSLIOHandlerSocketOpenSSL, but still the app is crashing when I call any service methods like PUT, POST, GET.

Please help me on this.

2

There are 2 best solutions below

0
On BEST ANSWER

I have tried with TNetHTTPClient , and it works fine with HTTPS protocols.

1
On

Indy's native support for SSL/TLS is broken (well, incomplete) on Android 6+, because Google dropped support for OpenSSL in Android 6, switching to their own internal modified fork named BoringSSL:

Android 6.0 Changes - BoringSSL

Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app [which Delphi Android apps do], don't link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.

TIdSSLIOHandlerSocketOpenSSL does not work with BoringSSL, and Indy does not have another SSLIOHandler class for BoringSSL at this time. This is an open issue that has not been resolved yet:

#166 Support BoringSSL on Android 6

Until that is resolved (and there is no ETA on that), you will have to either:

  1. deploy OpenSSL binaries for Android (available from https://indy.fulgan.com/SSL/) with your Android app, and instruct Indy where to load them from at runtime. But depending on device and system configuration, this may or may not work. People have had mixed results on this matter.

  2. write your own TIdSSLIOHandlerSocketBase-derived class that uses Java socket APIs instead of C library BSD sockets and OpenSSL.