Keytool: How to solve javax.net.ssl.SSLHandshakeException Error?

A java microservice function exception in the environment, look at the logs reporting errors.
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

Reason: The self-signed certificate used by the customer is not trusted by jdk.

Import the customer domain SSL certificate into jdk library.

# export LANG=”en_US.UTF-8″
# openssl s_client -connect www.example.com:443 < /dev/null | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > www.example.com.crt
# keytool -import  -file  www.example.com.crt  -alias  www.example.com  -keystore $JAVA_HOME/jre/lib/security/cacerts  –storepass “changeit” –noprompt   -trustcacerts

Restart the relevant java application and solve it.


Read More: