Java import certificate from website
Making calls to a server with a self signed certificate might give you the following 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
To fix this we need to import the certificate of this website into our local keystore.
Default pw for the keystore is ‘changeit’.
openssl s_client -showcerts -connect www.example.com:443 < /dev/null | openssl x509 -outform DER > www.example.com.der keytool -importcert -trustcacerts -alias www.example.com -file www.example.com.der -keystore <path_to_keystore> |
Categories: Uncategorized