I am facing an SSL issue same as in the link Java 8 SSL issues - works properly with Java 7
Below is the actual query.
I am consuming a web service which uses SSL certificate, they have provided PKCS12 certificate. Generated JKS using keytool, certificate is working fine in SOAPUI.
My project is using Java 8, but when I try to invoke service using JKS it shows com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Rejected by policy.
Tried same with Java 7, it is working fine and getting response from the service. Below is the code
SSLContext sc = SSLContext.getInstance("TLSv1.2"); KeyManagerFactory kmf =KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() ); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ks.load(new FileInputStream ("MYCLIENTCERT.JKS"), "keystorepassword".toCharArray() ); kmf.init( ks, "sourcepassword".toCharArray() ); sc.init( kmf.getKeyManagers(), null, null ); ((BindingProvider) bp).getRequestContext().put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory",sc.getSocketFactory() );
PKCS12 given directly in java 7, that also working fine, not in Java8 (jdk1.8.0_131)
KeyStore ks = KeyStore.getInstance("PKCS12"); ks.load(new FileInputStream ("filename.p12"), "sourcepassword".toCharArray() ); kmf.init( ks, "sourcepassword".toCharArray() );
Have tried so many option but seems nothing is working. Any help would be appreciated.