Software >> Development >> Languages >> Java >> Tools >> Keytool >> How to use java keytool for managing SSL certifications in keystores
Java Keytool Commands for Creating and Importing These commands allow you to generate a new Java Keytool keystore file, create a CSR, and import certificates. Any root or intermediate certificates will need to be imported before importing the primary certificate for your domain.
keytool -genkey -alias mydomain -keyalg RSA -keystore keystore.jks -keysize 2048
keytool -certreq -alias mydomain -keystore keystore.jks -file mydomain.csr
keytool -import -trustcacerts -alias root -file Thawte.crt -keystore keystore.jks
keytool -import -trustcacerts -alias mydomain -file mydomain.crt -keystore keystore.jks
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048 Java Keytool Commands for Checking If you need to check the information within a certificate, or Java keystore, use these commands.
keytool -printcert -v -file mydomain.crt
keytool -list -v -keystore keystore.jks
keytool -list -v -keystore keystore.jks -alias mydomain Other Java Keytool Commands
keytool -delete -alias mydomain -keystore keystore.jks
keytool -storepasswd -new new_storepass -keystore keystore.jks
keytool -export -alias mydomain -file mydomain.crt -keystore keystore.jks
keytool -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts
keytool -import -trustcacerts -file /path/to/ca/ca.pem -alias CA_ALIAS -keystore $JAVA_HOME/jre/lib/security/cacerts |