Converting JKS to PEM format
Published (last updated )
# change the password on the java keystore (originally set by ca)
keytool -storepasswd -new changeit -keystore tomcat.jks
# change the password of the alias/user too
keytool -keypasswd -alias auth -keystore tomcat.jks
# rename the alias to something tomcat expects
keytool -changealias -alias auth -destalias tomcat -keystore tomcat.jks
# convert the java keystore to pkcs12 format
keytool -importkeystore -srckeystore tomcat.jks -destkeystore tomcat.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass changeit -deststorepass changeit -srcalias tomcat -destalias tomcat -srckeypass changeit -destkeypass changeit -noprompt
# convert the pkcs12 keystore to pem format
openssl pkcs12 -in tomcat.p12 -out tomcat.pem -passin pass:changeit -passout pass:changeit
# read the certificate from the pem bag and store as-is
openssl x509 -in tomcat.pem -out tomcat.crt
# read the private key from the pem bag and store decrypted
openssl rsa -in tomcat.pem -out tomcat.key