1

I can build openssl-1.0.2j successfully for android (libcrypto.so and libssl.so) using GitHub stdchpie/android-openssl:

  • Environment: Linux OS, (my case I use Mac OS)

  • Android NDK: 12b

On Android 5.x if using:

System.loadLibrary("crypto");
System.loadLibrary("ssl");

It will get conflict with native OS libs which also have same names. And unluckily, manually change their names didn't work. So that I want to compile them into different names , like libcryptox.so and libsslx.so

I try to play with Makefile.org all day but not lucky. So please someone tell me how to do.

jww
  • 97,681
  • 90
  • 411
  • 885
kairen
  • 235
  • 3
  • 13
  • 2
    The reason that just renaming the library doesn't work is that shared libraries have a bit of metadata in the ELF header called `SONAME`. Android (at least newer versions, don't know if this holds true all the way back to GB) use that for `loadLibrary`. – Dan Albert Oct 03 '16 at 18:34
  • 1
    You have to write a wrapper shared object. The wrapper shared object exports the functionality you need. It also statically links to OpenSSL so you don't get the down-level version of OpenSSL loaded by Zygote. Also see [How to build OpenSSL as unversioned shared lib](http://stackoverflow.com/a/24212330/608639) and [Changing OpenSSL library in Android app for HttpClient](http://stackoverflow.com/a/28392326/608639). – jww Oct 03 '16 at 18:58
  • Also see [OpenSSL and Android](https://wiki.openssl.org/index.php/Android) on the OpenSSL wiki; and [Updating Your Security Provider to Protect Against SSL Exploits](http://developer.android.com/training/articles/security-gms-provider.html) in the Android docs. – jww Oct 03 '16 at 19:09

1 Answers1

0

The system has those libs loaded in the run-time environment, you can't use the System.loadLibrary

You can make small ndk code that will use native dload for those libs. And eventually, I think its best to use the ssl api's through the common android API as you never know what they will do next version.

skoperst
  • 2,259
  • 1
  • 23
  • 35