When I am using truststore and keystore using vm option in intellij or eclipse , i am able to make SSL connection correctly,
-Djavax.net.ssl.keyStore=<path>\keystore.jks
-Djavax.net.ssl.keyStorePassword=xxxx
-Djavax.net.ssl.trustStore=<path>\truststore.jks
-Djavax.net.ssl.trustStorePassword=xxxx
But when I am using the same args programatically in Springboot main method it fails with below error:
System.setProperty("javax.net.ssl.keyStore", "classpath:keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword","xxxx");
System.setProperty("javax.net.ssl.trustStore","classpath:truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword","xxxx");
Errors that I get:
Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing
implementation (algorithm: Default, provider: SunJSSE, class:
sun.security.ssl.SSLContextImpl$DefaultSSLContext)
Caused by: java.security.KeyStoreException: problem accessing trust store
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
Caused by: java.security.UnrecoverableKeyException: Password verification failed
Anything I am missing here ? Thanks in Advance !