-
Export the certificate using the
keytool command-line utility:
# keytool -export -rfc -alias my_cert -file cert.crt -keystore keystorename -storepass keystorepassword
-
Download ExportPriv.java from http://mark.foster.cc/pub/java/ExportPriv.java.
-
Download Base64Coder.java from http://www.source-code.biz/snippets/java/2.htm.
-
Rename Base64Coder.java without the ".txt" extension.
-
Compile ExportPriv.java and Base64Coder.java:
# javac ExportPriv.java Base64Coder.java
-
Export the private key to "exported.key" in PKCS#8 PEM format:*
# java -classpath . ExportPriv <keystore> <alias> <password> > exported.key
-
Convert the private key "exported.key" to "exported_rsa.key" in RSA format:
# openssl pkcs8 -inform PEM -nocrypt -in exported.key -out exported_rsa.key