keytool command
keytool command location : $JAVA_HOME/jre/bin/keytool
cacerts location : $JAVA_HOME/jre/lib/security/cacerts
(Generally this is the location of keytool command or cacerts, It may vary based on your environment)
cacerts location : $JAVA_HOME/jre/lib/security/cacerts
(Generally this is the location of keytool command or cacerts, It may vary based on your environment)
Parameters for below examples
Certifcate Filename: testcert.cer
Keystore Name: cacerts
Importing Certificate
keytool -import -trustcacerts -alias "Alias_Name" -file "Filename" -keystore "keystore_Name"
Example:
keytool -import -trustcacerts -alias "This is a cert" -file testcert.cer -keystore cacerts
This above command will import testcert.cer into the keystore cacerts with the label "This is a cert"
Listing Certificate
keytool -list -keystore "keystore_name"
Examples:
keytool -list -keystore cacertsLists all the certificates in the keystore cacerts
keytool -list -v -keystore cacerts
Lists all the details of all certificates in the keystore cacerts
keytool -list -alias "This is a cert" -keystore cacerts
Lists the certificate withe the Alias "This is a cert" in the kestore cacerts
Lists the certificate withe the Alias "This is a cert" in the kestore cacerts
keytool -list -v -alias "This is a cert" -keystore cacerts
Lists the certificate with the label "This is a cert" in the keystre cacerts
keytool -list -v -keystore cacerts |grep Alias
Lists the Alias of all the certificates in the keystre cacerts.
keytool -delete -alias "Alias_Name" -keystore "Keystore_Name"
Lists the certificate with the label "This is a cert" in the keystre cacerts
keytool -list -v -keystore cacerts |grep Alias
Lists the Alias of all the certificates in the keystre cacerts.
Deleting the certificate
keytool -delete -alias "Alias_Name" -keystore "Keystore_Name"