Android 上具有 SSLCaching 和密钥库的 HttpClient
我想使用 SSL 客户端身份验证和 SSL 缓存连接到 https 服务器。据我所知,你只能选择其中之一,但我不明白为什么会这样。
目前我正在使用 DefaultHttpClient,它采用 ClientConnectionManager,我已经使用加载了 pkcs12 KeyStore 的 SSLSocketFactory 设置了 ClientConnectionManager,以便我可以执行 SSL 客户端身份验证。
我还发现 SSLCertificateSocketFactory.getHttpSocketFactory() 可以传递 SSLSessionCache。
然后我注册套接字工厂
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https",socketFactory , port));
并使用注册表创建 ClientConnectionManager 和 HttpClient
ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager(httpParameters, registry);
httpClient = new DefaultHttpClient(ccm, httpParameters);
但我不知道如何为 SSLSocketFactory 提供 SSLSessionCache 或 SSLCertificateSocketFactory 密钥库
最后我研究了使用 AndroidHttpClient 您可以传递一个 Context它将用于 SSLCaching,但我找不到任何方法让 AndroidHttpClient 使用我的 ClientConnectionManager。
我错过了什么还是这真的不可能?
谢谢
I want to make a connection to an https server using SSL client authentication and SSL caching. As far as I can tell you can only have one or the other and I dont see a reason why that would be.
Currently I am using a DefaultHttpClient which takes a ClientConnectionManager which I have set up with an SSLSocketFactory loaded with a pkcs12 KeyStore so I can perform the SSL client authentication.
I also found SSLCertificateSocketFactory.getHttpSocketFactory() which can be passed an SSLSessionCache.
I then register the socket factory
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https",socketFactory , port));
and use the registry to make a ClientConnectionManager and then an HttpClient
ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager(httpParameters, registry);
httpClient = new DefaultHttpClient(ccm, httpParameters);
but I dont know how to give either the SSLSocketFactory an SSLSessionCache, or the SSLCertificateSocketFactory a keystore
Lastly I looked into using an AndroidHttpClient which you can pass a Context which it will use for SSLCaching, but I cannot find any way to get an AndroidHttpClient to use my ClientConnectionManager.
Am I missing something or is this really impossible?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HttpClient 内置了 SSL 会话缓存,据我了解,SSLSessionCache 用于 HttpsURLConnection。
它没有很好的记录是吧。
HttpClient has SSL session caching inbuilt, SSLSessionCache is for HttpsURLConnection as I understand it.
It's not very well documented is it.