How to use the Java Keytool command
It is believed that many inexperienced people have no idea about how to use the Java Keytool command. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The Java Keytool command uses the
If you do not have the Keytool tool, please install jre/jdk first (no details on how to install it here)
Generate a private key
Keytool-genkey-alias getssl-keyalg RSA-keystore www.getssl.cn.jks-keysize 2048
Generate CSR
Keytool-certreq-alias getssl-keystore www.getssl.cn.jks-file getssl.csr
Import a root certificate or intermediate certificate
Keytool-import-trustcacerts-alias root-file GeoTrust.crt-keystore www.getssl.cn.jks
Import certificates issued by CA
Keytool-import-trustcacerts-alias getssl-file www.getssl.cn.crt-keystore www.getssl.cn.jks
Generate a self-signed certificate (optional, you can use this item if you do not want to purchase a certificate, the browser cannot trust it)
Keytool-genkey-keyalg RSA-alias selfsigned-keystore keystore.jks-storepass password-validity 360-keysize 2048
Query imported certificates based on Alias name
Keytool-list-v-keystore keystore.jks-alias getssl
Delete the imported certificate based on the Alias name
Keytool-delete-alias getssl-keystore keystore.jks
Change the password of Keystore file
Keytool-storepasswd-new New password-keystore keystore.jkskeytool-keypasswd-alias 1-new New password-keystore keystore.jks
Export the certificate based on the Alias name
Keytool-export-alias getssl-file myssl.crt-keystore keystore.jks
Export private key
Keytool-importkeystore-srckeystore www.getssl.cn.jks-destkeystore keystore.p12-deststoretype PKCS12openssl pkcs12-in keystore.p12-nodes-nocerts-out mydomain.key
Show CA trust certificate
Keytool-list-v-keystore $JAVA_HOME/jre/lib/security/cacerts
Import an CA certificate into the JAVA trust list
Keytool-import-trustcacerts-file / path/to/ca/ca.pem-alias mydomain-keystore $JAVA_HOME/jre/lib/security/cacerts
Certificate format conversion
Convert PFX to JKS
Keytool-importkeystore-srckeystore mypfxfile.pfx-srcstoretype pkcs12-destkeystore newjkskeystore.jks-deststoretype JKS
Convert JKS to PFX
Keytool-importkeystore-srckeystore myjksfile.jks-srcstoretype JKS-deststoretype PKCS12-destkeystore newpfxkeystore.pfx after reading the above, have you mastered how to use the Java Keytool command? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!