I have a Java project built with myEclipse, Java 1.7. Project call two clients that make Rest request on two different SSL web services end-point.
..
public void Example() {
..
CallFirstClient();
CallSecondClient();
..
}
First client need certificate, second client doesn't need certificate. If I execute second client alone, it work without certificate. In first client I load certificate and it work:
System.setProperty("javax.net.ssl.trustStore", pathKeyStore);
System.setProperty("javax.net.ssl.trustStorePassword", "password");
System.setProperty("javax.net.ssl.keyStore", pathKeyStore);
System.setProperty("javax.net.ssl.keyStorePassword", "password");
After execution of first client (with certificate), second doesn't work because have problem with certificate (but it doesn't need!).
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
I tried to clear, into the second client, system properties:
System.setProperty("com.sun.net.ssl.checkRevocation", "false");
System.clearProperty("javax.net.ssl.trustStore");
System.clearProperty("javax.net.ssl.trustStorePassword");
System.clearProperty("javax.net.ssl.keyStore");
System.clearProperty("javax.net.ssl.keyStorePassword");
But it doesn't work. Anyone can help me?
SOLUTION
The second client is developed with Java 1.6 that doesn't make control about certificate of SSL connection. So, when I execute the client alone without keystore, it work!
My Java project (Example) is developed with Java 1.7 that make control about certificate. So, the solution is: