Extracting the Private Key from a Java Keystore

From Peter Pap's Technowiki
Jump to: navigation, search

So you want to move away from using Tomcat and want to extract the server private key. Here's what you need to do:

 keytool -importkeystore -srckeystore server.jks -destkeystore server.pkcs -srcstoretype JKS -deststoretype PKCS12
 openssl pkcs12 -in thekeystore.p12 -nocerts -nodes -out serverkey.pem

serverkey.pem no contains your server private key.