Problems with httpclient and selfsigned certificat

2019-07-24 11:36发布

问题:

I am sure this has been discussed in this group, but I couldn't find that thread, so bear with it, or if possible merge it with the original.

I am using httpclient for my android app and I have a local site which has a few https pages. Since default httpclient doesnot allow self-signed certificates I am using "EasySSLFactory" and "EasyX509TrustManager", which are mentioned in httpclient documentation.

client = new DefaultHttpClient(); client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", new EasySSLSocketFactory(), 443));

The problem is if I use this SSLFactory in my android app, I am getting correct response from my site's https pages, but I get "SSL handshake failure: I/O error during system call, Unknown error: 0" for sites such as "gmail.com", "ymail.com". If I don't use "EasySSLSocketFactory" I get response from these sites but get exception for my site.

The funny thing is that this page fetch code works fine as a standalone java application.

What could be the problem. Please help me with this.

Thanks and Regards

回答1:

Solved it for now, since I had just one certificate I put it in emulator's keystore. If somebody has better solution, please let me know.