How to export .key and .crt from the keystore
When I build an android app on my dev machine, I need to provide an SSL certificate for the app, so I generate a keystore for Tomcat using keytool. I pulled the certificate from the keystore and put it in .bks to use android and everything went well.
Now we have to move all the server-side code to servers that need Apache HTTP and Tomcat. Apache HTTP SSL requires .key and .crt files, and I can’t find a way to export .key and .crt files from the keystore
Can someone help? I found that you can generate .crt from .pem
openssl x509 -outform der -in your-cert.pem -out your-cert.crt
But how can I get .key documents?
Keytool (available in the JDK) allows you to export certificates to a file:
keytool -exportcert -keystore [keystore] -alias [alias] -file [cert_file]
To export a regular key, you should use the -importkeystore command (surprise):
keytool -importkeystore -srckeystore [keystore] -destkeystore [target-keystore] -deststoretype PKCS12