Tuesday, August 18, 2009

How to call web services having SSL mutual authentication enabled?

First - your client needs to trust the service's certificate.

So - import the CA cert who signed service's certificate, to your trust store at the client side.

Then you need to set following in your client code;

System.setProperty("javax.net.ssl.trustStore", "truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "wso2carbon");

keystore.jks will have your public certificate.

Or else, you can pass these parameters in command line as well;

\> client -Djavax.net.ssl.trustStore=truststore.jks
-Djavax.net.ssl.trustStorePassword=wso2carbon
-Djavax.net.ssl.trustStoreType=JKS
-Djavax.net.ssl.keyStore=keystore.jks
-Djavax.net.ssl.keyStorePassword=wso2carbon

0 comments:

Post a Comment