Skip to content

Pipeliner/openssl-curl-android

 
 

Repository files navigation

openssl-curl-android

Compile openssl and curl for Android. This is a personal fork of robertying/openssl-curl-android.

Prerequisites

Make sure you have Android NDK installed.

And also necessary autoconf and libtool toolchains.

Download

If you do not want to compile them yourself, you can download pre-compiled binaries and static libraries from releases. They are built by CircleCI: CircleCI

Usage

git clone https://github.com/robertying/openssl-curl-android.git
git submodule update --init --recursive

export ANDROID_NDK_HOME=your_android_ndk_bundle_root_here
export HOST_TAG=see_this_table_for_info # https://developer.android.com/ndk/guides/other_build_systems#overview
export MIN_SDK_VERSION=21 # or any version you want

chmod +x ./build.sh
./build.sh

All compiled libs are located in build/openssl and build/curl directory.

Use NDK to link those libs, part of Android.mk example:

include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := build/curl/$(TARGET_ARCH_ABI)/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)

Options

Change scripts' configure arguments to meet your requirements.

For now, using tls (https) in Android would throw peer verification failed.

Please explicitly set curl_easy_setopt(curl, CURLOPT_CAINFO, CA_BUNDLE_PATH); where CA_BUNDLE_PATH is your ca-bundle in the devide storage.

You can download and copy cacert.pem to the internal storage to get tls working for libcurl.

Working Example

Checkout this repo to see how to integrate compiled static libraries into an existing Android project, including Android.mk setup and JNI configurations.

About

Compile openssl and curl for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%