javax.net.ssl.SSLException: SSL handshake aborted on android old devices

后端 未结 2 725
忘掉有多难
忘掉有多难 2020-12-13 00:50

I have android application that was working fine for most of devices Recently some hackers tried to make DDOS attack on our servers that force us to add some security and so

2条回答
  •  情话喂你
    2020-12-13 01:32

    Use this in your code before making any network call

    /**
     * Initialize SSL
     * @param mContext
     */
    public static void initializeSSLContext(Context mContext){
        try {
            SSLContext.getInstance("TLSv1.2");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        try {
            ProviderInstaller.installIfNeeded(mContext.getApplicationContext());
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }
    

    I had the same problem and this piece of code solved my problem. FYI: I was using retrofit library for making network calls

    You need to include below line in build.gradle

    implementation 'com.google.android.gms:play-services-safetynet:17.0.0
    

    Thanks @Houman for the above input

提交回复
热议问题