javax.net.ssl.SSLHandshakeException: Handshake failed on Android 5.0.0 when SSLv2 and SSlv3 are disabled (TLS only) (and greater)

后端 未结 4 679
太阳男子
太阳男子 2020-12-24 15:55

This is my first post and I\'m going to try to do my best to be as clear as possible (sorry for my english).

Here is my trouble, I\'m using retrofit:1.9.0 and okhttp

4条回答
  •  死守一世寂寞
    2020-12-24 16:15

    I found the solution here in this link.

    You just have to place below code in your Android application class. And that is enough. Don't need to do any changes in your Retrofit settings. It saved my day.

    public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        try {
          // Google Play will install latest OpenSSL 
          ProviderInstaller.installIfNeeded(getApplicationContext());
          SSLContext sslContext;
          sslContext = SSLContext.getInstance("TLSv1.2");
          sslContext.init(null, null, null);
          sslContext.createSSLEngine();
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException
            | NoSuchAlgorithmException | KeyManagementException e) {
            e.printStackTrace();
            }
        }
    }
    

    Hope this will be of help. Thank you.

提交回复
热议问题