When I am trying to access a \'https\' web service from my app , it is giving a \'javax.net.ssl.SSLHandshakeException: Connection closed by peer\' error. Th
try use this code, it work for me :
private 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();
}
}
and don't forget to usr google security library :
compile 'com.google.android.gms:play-services-safetynet:11.6.2'