5

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 ?

ilw
  • 2,499
  • 5
  • 30
  • 54
  • 2
    You should explain why you are using `google-conscrypt`. My guess is TLS 1.3, see: [How to enable TLSv1.3 for OkHttp 3.12.x on Android 8/9?](https://stackoverflow.com/q/55539513/295004) – Morrison Chang Dec 04 '20 at 09:03

1 Answers1

0

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.

k_o_
  • 5,143
  • 1
  • 34
  • 43