Tuesday 19 November 2013

Java Keytool

I constantly forget how to use the keytool so here are some memory joggers!  The keytool app is part of the the standard Java distribution.

These will be added to over time.

List

List the contents of a jks file

    keytool -list -keystore <keystore.jks> -storepass <password>

Remote Keys

Print a certificate for a remote server


   keytool -printcert -rfc -sslserver my.company.com

Copy the output into a file .pem

Import Key

Import a key to a key store.  In this case it is imported into the java default Certificate Authority file (cacerts).  This will prompt for a password for the cacerts file which is 'changeit' by default.

    keytool -importcert -file ./certificate.pem -keystore $JRE_LIB/lib/security/cacerts

No comments:

Post a Comment