I am trying to send an email over SSL, I already have the certificate and I have imported it into my cacerts file. I assumed that by default, java would look for the cacerts file in the java_home, or in the jdk specified for the project. This is not the case and so I set the system property for the keystore and truststore to point to the path where my cacerts is found, I did this in the following way:
System.setProperty("javax.net.ssl.keyStore", JAVA_HOME + "\\jre\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.trustStore",JAVA_HOME + "\\jre\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.keyStorePassword", password);
System.setProperty("javax.net.ssl.trustStorePassword", password);
This doesn't work either, even after specifying the path I keep getting the following error:
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I have read numerous posts on here (Stackoverflow) and even other websites and I can't manage to get this to work. Does anyone know why this is happening? Or maybe you can tell me if there are things that I should check before.