httpclient和自签名证书的问题 [英] Problems with httpclient and selfsigned certificates

查看:138
本文介绍了httpclient和自签名证书的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信这个已经在这个小组中进行了讨论,但是我找不到那个帖子,所以请耐心等待,或者如果可能的话将它与原始版本合并。



<我正在使用httpclient为我的Android应用程序,我有一个本地网站有几个https页面。由于默认的httpclient不允许自签名证书,我使用的是EasySSLFactory和EasyX509TrustManager,这些都在httpclient
文档中提到。




client = new 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

解决方案

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.

这篇关于httpclient和自签名证书的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆