Defaulthttpclient Android Ssl No Peer Certificate And Handshake Failed
I have to connect api https://mywebsite.com 443 HttpClient httpClient = new DefaultHttpClient(); it's not work alert error : no peer certificate I try to search how to fix this
Solution 1:
That error usually occurs when android falls back to SSLv3 from TLSv1.
Try below solution:
Open your Application
class and write below code in its onCreate()
method.
try {
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();
}
Post a Comment for "Defaulthttpclient Android Ssl No Peer Certificate And Handshake Failed"