Search code examples
javaweb-servicessslhttpsapache-axis

Consuming Webservice and 2 way SSL


Consuming Webservice over HTTPS

We have a webservice that we are consuming from our end.

Webservice can run both on HTTP and HTTPS protocol. With HTTP no issues, but how to access with HTTPS.

Can anybody tell me the java code for the same. I need to do this at the application level.

Keystores and truststores will be required but how to use in java code and and trust them.

Any help will be appreciated.


Solution

  • The server authentication part should be easy. Just stick the required cert(s) in the provided cacerts truststore.. see this documentation for some info on using keytool to work with the cacerts truststore.

    As far as the client authentication part, I'd look at some other questions here on Stack Overflow for your answer or at least some code to get you started. Here are some questions you should look at:

    Creating SSL Client with Axis2/JAVa, and Choosing SSL client certificate in Java should be a couple for you to look at.

    Last, I'm going to submit another edit to add the 'axis2' tag to your question. That should get some more people looking at this that have the appropriate experience.