我必须通过双向身份验证访问webservice。以下是我的方法。
创建了MyCustomSSLSocketFactory类。
我在调用webservice方法之前调用了这个类方法。
然后我做了如下: -
AxisProperties.setProperty("axis.socketSecureFactory",
"com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");
Security.setProperty("ssl.SocketFactory.provider",
"com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");
SSLContext context = SSLContext.getInstance(protocolVersion);
context.init(keyManagers, trustManagers, null);
SSLSocketFactory socketFactory = context.getSocketFactory();
URL url = new URL(urlString);
URLConnection connection = url.openConnection();
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection)
.setSSLSocketFactory(sslSocketFactory);
connection.connect();
}
当我访问网络服务时,它会给我以下错误。
org.apache.axis2.AxisFault: Unconnected sockets not implemented
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
如果我错过了什么,请告诉我。
答案 0 :(得分:1)
问题得到解决,只需在cacerts文件中导入证书。
答案 1 :(得分:0)
我认为这可能是这个Java错误 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6771432
请注意,这应该在java 1.6.0_u14
中修复