Skip to content

Instantly share code, notes, and snippets.

@reflexdemon
Last active July 27, 2019 11:21
Show Gist options
  • Save reflexdemon/556f872d5425ef96290904888619f499 to your computer and use it in GitHub Desktop.
Save reflexdemon/556f872d5425ef96290904888619f499 to your computer and use it in GitHub Desktop.
Downloading PEM certificate using OpenSSL and importing to Java TrustStore

Download the Certificate using OpenSSL Command

echo "" | openssl s_client -connect server-that-you-want-to-connect:port -showcerts 2>/dev/null | openssl x509 -out cert.pem

Import the downloaded certificate using Java 11 to truststore

keytool -import -storepass changeit -noprompt -file cert.pem -cacerts

Import the downloaded certificate using Java 8 to truststore

keytool -import -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit -noprompt -file cert.pem -cacerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment