httpclient 和自签名证书的问题
我确信这个小组已经讨论过这个问题,但我找不到那个线程,所以请耐心等待,或者如果可能的话将其与原始线程合并。
我正在为我的 Android 应用程序使用 httpclient,并且我有一个本地站点,其中有几个 https 页面。由于默认的 httpclient 不允许自签名证书,我正在使用 httpclient 中提到的“EasySSLFactory”和“EasyX509TrustManager” 文档。
<代码> 客户端 = 新的 DefaultHttpClient(); client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", new EasySSLSocketFactory(), 443)); 问题
是,如果我在 Android 应用程序中使用此 SSLFactory,我会从网站的 https 页面获得正确的响应,但会收到“SSL 握手失败:系统调用期间出现 I/O 错误,未知错误:0”的消息网站,例如“gmail.com”、“ymail.com”。如果我不使用 “EasySSLSocketFactory”我从这些网站得到响应,但我的网站出现异常。
有趣的是,这个页面获取代码作为独立的 java 应用程序运行良好。
可能是什么问题。请帮我解决这个问题。
感谢和问候
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.