Java keytool useful commands

Here are some useful commands when manipulating Java keystores. (I will update this post from time to time)

(default keystore password: changeit)

Import a certficate into a Java keystore

keytool -import -keystore /jre/lib/security/cacerts -file mycertificate.der

Import a list of certificates into a Java keystore


for file in /app/certs/* 
    if [[ -f $file ]]; then
        keytool -noprompt -storepass changeit -import -keystore $JAVA_HOME/jre/lib/security/cacerts -file $file -alias $file

List the certificates of a keystore in a file report.txt

keytool -list -v -keystore /jre/lib/security/cacerts > report.txt

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.