I have to access the webservice with 2 way authentication. Below is my approach.
Created MyCustomSSLSocketFactory class.
- Loaded TrustManagers
- Loaded Keystore Managers
- Created SSL Context and SSL socket factory as below.
I call this class method just before calling webservice method.
Then i have done as below:-
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();
}
when i access the webservice it gives me below error.
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)
Please let me know if i am missing anything.
I think it could be this Java bug – https://bugs.java.com/bugdatabase/view_bug?bug_id=6771432
Note that this is supposedly fixed in java 1.6.0_u14