Enable TLS 1.2 in Android 4.4

后端 未结 2 1299
闹比i
闹比i 2020-12-30 11:49

I use Retrofit and OkHttp3 for making requests. I konw that in Android 4.4 TLS 1.1 and TLS 1.2 are not enabled by defult. So i\'m trying to enable them. But so far i had no

相关标签:
2条回答
  • 2020-12-30 12:15

    Please try this: https://developer.android.com/training/articles/security-gms-provider.html.

    It is using https://developers.google.com/android/reference/com/google/android/gms/security/ProviderInstaller, you need to have Google API in your project.

    You need to just call in your Application:

    @Override
    public void onCreate() {
        super.onCreate();
        try {
            ProviderInstaller.installIfNeeded(this);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }
    

    You should also remove your custom SSLfactory.

    0 讨论(0)
  • 2020-12-30 12:33

    That error usually occurs when android falls back to SSLv3 from TLSv1. It is a bug in pre-lollipop devices.

    The solution is to remove SSLv3 using Android's security Provider.

    try this solution:

    private void updateAndroidSecurityProvider(Activity callingActivity) {
        try {
            ProviderInstaller.installIfNeeded(this);
        } catch (GooglePlayServicesRepairableException e) {
        GooglePlayServicesUtil.getErrorDialog(e.getConnectionStatusCode(), callingActivity, 0);
        } catch (GooglePlayServicesNotAvailableException e) {
            Log.e("SecurityException", "Google Play Services not available.");
        }
    }
    
    0 讨论(0)
提交回复
热议问题