I am using spring template to connect to ldap server over ssl. I used the following command to save ssl certificate from server:
echo -n | openssl s_client -connect <ldapserverip>:<port> | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ldapserver.pem
Then went to /jre/lib/security directory and executed the following command to add certificate to cacerts.
keytool -import -keystore cacerts -file ldapserver.pem
Then verified the count in list of entries in cacerts using the command:
keytool -list -keystore cacerts
I am running the application in tomcat and tomcat is pointed to same JDK_HOME.
I am getting the following exception in tomcat while logging in using authenticate() in ldapTemplate using spring.
Root exception is 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
It was working fine with plain text (with out https). I tried setting VMArguments as well but none of them worked.
-Djavax.net.ssl.trustStore="<path to cacerts file>"
-Djavax.net.ssl.trustStorePassword="<passphrase>"
How can i solve this issue?
Thanks