I'm developing a Springboot application that will communicate with a server having SOAP Web service. Mutual authentication or 2-Way SSL authentication is used for the communication. I have looked the suggestions given here and here and have set the following: -
In application.properties
server.ssl.key-alias=testclient
server.ssl.key-password=password
server.ssl.key-store=classpath:testclientselfsigned
server.ssl.key-store-password=password
server.ssl.key-store-type=JKS
server.ssl.trust-store=classpath:myTruststore
server.ssl.trust-store-type=JKS
server.ssl.trust-store-password=password
In my code calling the web service
static {
URL urlTruststore = ClassLoader.getSystemResource("myTruststore");
URL urlKeystore = ClassLoader.getSystemResource("testclientselfsigned");
if (urlTruststore != null) {
logger.info("URL TRUST STORE:\t" + urlTruststore.getFile());
System.setProperty("javax.net.ssl.trustStore", urlTruststore.getFile());
System.setProperty("javax.net.ssl.trustStorePassword","password");
}
if (urlKeystore != null) {
logger.info("URL KEY STORE:\t" + urlKeystore.getFile());
System.setProperty("javax.net.ssl.keyStore",urlKeystore.getFile());
System.setProperty("javax.net.ssl.keyStorePassword","password");
}
String WS_URL = "https://uatexample.testserv.com/uat/ssl/custService";
URL url = new URL(WS_URL);
QName qname = new QName("http://www.sampleserv.com/services", "custService");
Service service = Service.create(url, qname);
CustService client = service.getPort(CustService.class);
It is at this point CustService client = service.getPort(CustService.class);
that I'm getting the following exception
com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
Please note that myTruststore.jks contains the certificate sent to me by the server** and testclientselfsigned.jks contains the client certificate.
I have tried all the suggestions I found here to add a Keystore and Truststore in my code, but nothing worked. However, I have tried the same in Soap-UI and it worked.