On macOS sierra, some Java program encountered error: 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
Popular google answer suggested to use keytool to add certificate to $JAVA_HOME/jre/lib/security/cacerts.This solution probably works on other OS like Ubuntu, but it does not work on macOS sierra. I still got such error after adding certificate to $JAVA_HOME.
The root cause is that the application in trouble does not refer to $JAVA_HOME/jre/lib/security/cacerts, but refer to a file in its own installation path like /Applications/ccollab_client/.install4j/jre.bundle/Contents/Home/jre/lib/security/cacerts. After I added certificate to this place, ccollab software works without problem.
Do a search, we’ll find a few cacerts file outside of $JAVA_HOME.
sudo find / -name cacerts -type f
like /Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/itms/java/lib/security/cacerts