等效于wsimport的org.apache.axis.components.net.SunFakeTrustSocketFactory [英] Equivalent of org.apache.axis.components.net.SunFakeTrustSocketFactory for wsimport
问题描述
当我使用Apache Axis生成webservice客户端存根时,我通过调用以下方法使用客户端存根禁用我的代码中的服务器证书信任检查
When I generate webservice client stubs using Apache Axis, I disable the server certificate trust check in my code using the client stubs by calling the following method
AxisProperties.setProperty("axis.socketSecureFactory",
"org.apache.axis.components.net.SunFakeTrustSocketFactory");
如何禁用通过运行生成的客户端存根的信任检查wsimport
?
我在运行一些测试代码时使用它。
I use this when I am running some test code.
推荐答案
该类中发生的一切都是虚假的提供信任商店经理,信任任何事物。知道这一点,你可以使用这篇文章把东西放在一起。
All that's happening in that class is the provision of a bogus trust store manager, that trusts anything. Knowing that, you can use this article and put something together.
-
首先简单信任管理器
public class EasyTrustManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] chain, String authType) {
//do nothing
}
public void checkServerTrusted(X509Certificate[] chain, String authType) {
//do nothing
}
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
}
然后将您的信任管理器提供给实例 SSLContext
,就像轴正在执行:
SSLContext sCtxt = SSLContext.getInstance("SSL");
sCtxt.init(null, new TrustManager[]{new EasyTrustManager()}, new java.security.SecureRandom());
通过调用 HttpsURLConnection#setDefaultSSLSocketFactory来设置自定义上下文
基于以下事实:所有Web服务调用都基于 HttpsURLConnection
的基础实例。此调用将通过 SSLContext#getContext
设置上下文,用于所有 https调用
Setup the custom context, by calling HttpsURLConnection#setDefaultSSLSocketFactory
based on the fact that all your web service calls are based on an underlying instance of HttpsURLConnection
. This call will setup the context, by way of SSLContext#getContext
, for all https calls
HttpsURLConnection.setDefaultSSLSocketFactory(sCtxt.getSocketFactory());
这篇关于等效于wsimport的org.apache.axis.components.net.SunFakeTrustSocketFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!