Notes by Peter Galonza(Пётр Галонза)
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Java Keystore

Commands

Import certificate

keytool -import -alias <alias> -file <file_name>.cer -storetype <type> -keystore <keystore_file>

View

keytool -list -v -keystore <keystore_file>

Create keystore

keytool -genkey -alias tmp -keyalg RSA -keystore <keystore_file> -keysize 2048 -storetype <type>
keytool -delete -alias tmp -keystore <keystore_file>

Change key password

keytool -keypasswd -alias <alias> -keystore <keystore_file>

Convert PEM into JKS

Convert PEM into PKCS12

openssl pkcs12 -export -in <cert name>.pem -inkey <key name>.pem -CAfile <CA name>.pem -out <certificate name>.p12 -name "<alias name>"

Create JKS

keytool -genkey -storetype JKS -keyalg RSA -alias tmp -keystore <keystore>.jks
keytool -delete -alias tmp -keystore keystore.jks

Convert PKCS12 into JKS

keytool -importkeystore -srckeystore <certificate name>.p12 -srcstoretype pkcs12 -storetype JKS -destkeystore <keystore name>.jks