I hope guys you can help me with this problem, I do all the research and tried anything I saw but it just cannot resolve my problem. What I want to do is that to trust all the SSL certicates in my app. All the solutions I saw was using URLHttpConnection but I need a working solution for AndroidHttpClient. See my code below:
AndroidHttpClient httpClient = null;
HttpResponse httpResponse;
Bundle responseBundle;
try{
httpClient = AndroidHttpClient.newInstance("android");
httpClient = addCustomCertificate(httpClient);
httpResponse = httpClient.execute(request);
responseCode = httpResponse.getStatusLine().getStatusCode();
message = httpResponse.getStatusLine().getReasonPhrase();
HttpEntity entity = httpResponse.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
String response = convertStreamToString(instream);
responseBundle = new Bundle();
responseBundle.putString("result", response);
responseBundle.putInt("responseCode", responseCode);
receiver.send(method, responseBundle);
instream.close();
httpClient.close();
}
}
//====
private AndroidHttpClient addCustomCertificate(AndroidHttpClient client)
{
SSLSocketFactory sf = SSLSocketFactory.getSocketFactory();
try
{
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
sf = new SSLSocketFactory(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}
catch (Exception t)
{
t.printStackTrace();
}
client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", sf, 443));
return client;
}
But I'm always getting the error show in the image I captured in my logs. I cannot figure out what other solution can I do.