Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export .key and .crt from keystore

When I was building android app on development machine, I was required to have SSL certificate for app so I generated a keystore with keytool for Tomcat. I extracted the cert from keystore and put it into .bks for using android, and all went well.

Now we have to shift all server-side code to server which required Apache HTTP and Tomcat. Apache HTTP SSL requires .key and .crt files and I cannot find a way to export .key and .crt file from the keystore

Can anyone help with this? 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 file?

like image 561
Dusean Singh Avatar asked Apr 15 '14 15:04

Dusean Singh


People also ask

What is .key file and .CRT file?

The Certificate and Private Key Files crt extension) and a private key file (with the . key extension). The certificate file is a public-key certificate following the x. 509 standard. It contains information about the identity of the server, such as its name, geolocation, and public key.


1 Answers

Keytool (available in JDK) allows you to export certificates to a file:

keytool -exportcert -keystore [keystore] -alias [alias] -file [cert_file]

To export regular keys you should use -importkeystore command (surprise):

keytool -importkeystore -srckeystore [keystore] -destkeystore [target-keystore] -deststoretype PKCS12
like image 110
hoaz Avatar answered Oct 23 '22 11:10

hoaz