How to Use Java Keytool Command

Most Common Commands

List Certificates in Keystore

What

Command

Summary View

keytool -list -cacerts -storepass changeit

Linux: keytool -list -cacerts -storepass changeit | grep "string" 

Cmd: keytool -list -cacerts -storepass changeit | findstr "string" 

Pwsh: keytool -list -cacerts -storepass changeit | Select-String "string" 

Detail View keytool -list -v -cacerts -storepass changeit
Specific Certificate keytool -list -cacerts -storepass changeit -alias root
Specific File keytool -printcert -file kafka-prod-cacert.crt

Export/Import

What Command
Export keytool -export -alias root -file kafka-nonprod-cacart.crt -cacerts -storepass changeit
Delete keytool -delete -cacerts -storepass changeit -alias root
Import keytool -import -trustcacerts -alias kafka-nonprod-cacert -file kafka-nonprod-cacart.crt -cacerts -storepass changeit -noprompt

References