如何使用HTTP客户端传递客户端证书? [英] How do I pass the client certificate with HTTP client?

查看:211
本文介绍了如何使用HTTP客户端传递客户端证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务A和B之间使用相互SSL身份验证。我目前正在实现从Java中的服务A传递客户端证书。我正在使用Apache DefaultHttpClient来执行我的请求。我能够从内部凭证管理器检索我的服务A的客户端证书,并将其保存为字节数组。

I want to use mutual SSL authentication between service A and B. I'm currently implementing passing the client certificate from service A in Java. I'm using Apache DefaultHttpClient to execute my requests. I was able to retrieve the client certificate for my service A from an internal credential manager and I keep it as an array of bytes.

DefaultHttpClient client = new DefaultHttpClient();
byte [] certificate = localCertManager.retrieveCert();

我在这方面的经验很少,我很感谢你的帮助!

I have very little experience in this area and I'd appreciate your help!

我想也许它应该以某种方式通过HTTP客户端中的参数传递,或者可能在标题中传递。

I thought maybe it should be somehow passed through arguments in the HTTP client or maybe in the headers.

我如何通过HTTP客户端的客户端证书?

How do I pass the client certificate with HTTP client?

推荐答案

你需要告诉SSLSocketFactory(org.apache.http,而不是javax)你的密钥库,并配置您的DefaultHTTPClient以将其用于https连接。

You need to tell an SSLSocketFactory (org.apache.http, not javax) about your keystore, and configure your DefaultHTTPClient to use it for https connections.

此处的示例如下: http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/ client / ClientCustomSSL.java

这篇关于如何使用HTTP客户端传递客户端证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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