Skip to content

Instantly share code, notes, and snippets.

@pierrefevrier
Created July 20, 2017 15:09
Show Gist options
  • Save pierrefevrier/13fdf2a2ace9d67aaa85f7535268b30f to your computer and use it in GitHub Desktop.
Save pierrefevrier/13fdf2a2ace9d67aaa85f7535268b30f to your computer and use it in GitHub Desktop.
Java add certificate to trustStore
# Download ca certificate as .pem or .der
# [Step only for .pem certificates]
openssl x509 -outform der -in certificate.pem -out certificate.der
# Import .der certificate into Java trustStore
# "changeit" is the default password for alias
keytool -import -keystore path/to/cacerts -file certificate.der -storepass changeit -alias alias-of-your-certificate
# Verify certificates trusted
keytool -list -keystore path/to/cacerts -storepass changeit
# Force the use of a particular trustStore by your JVM
# Add the following instruction to your JAVA_OPTS
# -Djavax.net.ssl.trustStore=path/to/cacerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment