如何在JAX-WS客户端中禁用证书验证?
如何使用 javax.xml.ws.Service
在JAX-WS客户端中禁用证书验证?
How do you disable certificate validation in JAX-WS client using javax.xml.ws.Service
?
我尝试在SSLSocketFactory中创建一个完全信任的TrustManager,并尝试将其绑定到BindingProvider
I tried creating an all-trusting TrustManager in the SSLSocketFactory and tried to bind it with BindingProvider
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
Map<String, Object> ctxt = ((BindingProvider) wsport ).getRequestContext();
ctxt.put(JAXWSProperties.SSL_SOCKET_FACTORY, sc.getSocketFactory());
但我仍然得到异常:无法找到所请求目标的有效证书路径
但我只需使用
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
或者有没有办法让 javax.xml.ws.Service
使用我创建的 HttpsURLConnection
?
Or is there a way to make javax.xml.ws.Service
use the HttpsURLConnection
that I created?
我在这里找到了一个解决方案:
http://schrepfler.blogspot.com.br/2009/06/relaxing-ssl-validation-for-jaxws.html
I found a solution here: http://schrepfler.blogspot.com.br/2009/06/relaxing-ssl-validation-for-jaxws.html
我正在使用该解决方案在主类的静态块上调用两个静态方法,如下所示:
I'm using that solution calling the two static methods on a static block at the main class, like this:
static {
SSLUtilities.trustAllHostnames();
SSLUtilities.trustAllHttpsCertificates();
}
希望这会有所帮助