Requirement:
Application should call 3rd Party WSDL which is running on SSL port.
Problem:
Created Stub with Axis2. And tried to invoke WSDL but it throwing below exception :
Unable to sendViaPost to url[WSDLURL]: org.apache.axis2.AxisFault: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) [:1.6.2]
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:78) [:]
at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84) [:]
Solution:
1. Download Certificate by opening WSDL URL on browser with proper name.
2. Run Command prompt as Administrator
3. Run below command
keytool -import -trustcacerts -file -alias -keystore %JAVA_HOME%/jre/lib/security/cacert
Above command will prompt for password. Default password is "changeit" (without double quote)
Run your stub again... Hurray it's working !!!!
Assumption:
1. %JAVA_HOME% path pointing to same JDK to which your WSDL Client Stub getting executed.
2. is pointing to your downloaded certificate like C:/test.cer
3. can be your custom ALIAS.