mklimek / ssl-utils-android

The one line of code to trust custom certificate on Android

Home Page:https://mklimek.github.io/trust-specific-certificate-on-jvm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ssl-utils-android

More details in blog post: https://mklimek.github.io/trust-specific-certificate-on-jvm/

Add it in gradle:

top build.gradle:

    allprojects {
        repositories { 
            jcenter()
            maven { url "https://jitpack.io" }
        }
   }

module build gradle:

   dependencies {
        compile 'com.github.mklimek:ssl-utils-android:$RELEASE_VERSION'
   }

Get $RELEASE_VERSION from https://github.com/mklimek/ssl-utils-android/releases

Example usage:

Put your certificate into assets directory directly. In this case we have file BPClass2RootCA-sha2.cer.

OkHttpClient client = new OkHttpClient();
SSLContext sslContext = SslUtils.getSslContextForCertificateFile(context, "BPClass2RootCA-sha2.cer");
client.setSslSocketFactory(sslContext.getSocketFactory());

About

The one line of code to trust custom certificate on Android

https://mklimek.github.io/trust-specific-certificate-on-jvm/

License:MIT License


Languages

Language:Java 100.0%