How integrate the new conscrypt library to Android and use it by default

2.6k Views Asked by At

In android, if i get (SSLSocketFactory) SSLSocketFactory.getDefault() i get the inner socket factory with this class com.android.org.conscrypt.OpenSSLSocketFactoryImpl.

After adding this dependency

dependencies {
  implementation 'org.conscrypt:conscrypt-android:2.2.1'
}

I want to get (SSLSocketFactory) SSLSocketFactory.getDefault() the factory from new lib (org.conscrypt.OpenSSLSocketFactoryImpl), but still geting the inner com.android.org.conscrypt.OpenSSLSocketFactoryImpl. What is the integration algorithm for the new SocketFactory ?

1

There are 1 best solutions below

0
k_o_ On

You have to set the Conscrypt provider as first security provider, otherwise it will not be loaded:

Security.insertProviderAt(Conscrypt.newProvider(), 1);

Setting it as first provider will prevent Android from using the default one.