CXF RESTful客户端 - 如何信任所有证书? [英] CXF RESTful Client - How to do trust all certs?
本文介绍了CXF RESTful客户端 - 如何信任所有证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写的Jersey RESTful客户端使用 Dumb X509TrustManager和HostnameVerifier来信任我们实验室系统上的所有SSL证书,以便更轻松地处理自签名的证书。
I have written Jersey RESTful clients that made use of a Dumb X509TrustManager and HostnameVerifier to trust all SSL certs on our lab systems to make it easier to deal with certs that are self-signed.
ClientConfig config = new DefaultClientConfig();
SSLContext context = null;
try
{
context = SSLContext.getInstance("SSL");
context.init(null,
new TrustManager[] { new DumbX509TrustManager() },
null);
config.getProperties()
.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(this.getHostnameVerifier(),
context));
webClient = Client.create(config);
}
....
我有办法吗?类似的东西使用CXF?
Is there a way for me to do something similar using CXF?
推荐答案
这是来自CXF邮件列表。请注意,由于其他系统更新,我没有必要实现它,所以这是理论上的:
This is from the CXF mailing list. Note that I didn't have to implement it due to other system updates, so this is theoretical:
WebClient webClient = WebClient.create(this.serviceURL,
this.username,
this.password,
null); // Spring config file - we don't use this
if (trustAllCerts)
{
HTTPConduit conduit = WebClient.getConfig(webClient)
.getHttpConduit();
TLSClientParameters params =
conduit.getTlsClientParameters();
if (params == null)
{
params = new TLSClientParameters();
conduit.setTlsClientParameters(params);
}
params.setTrustManagers(new TrustManager[] { new
DumbX509TrustManager() });
params.setDisableCNCheck(true);
}
这篇关于CXF RESTful客户端 - 如何信任所有证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文