How to export .key and .crt from keystore

2020-07-09 03:04发布

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?

2条回答
叼着烟拽天下
2楼-- · 2020-07-09 03:30

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
查看更多
叼着烟拽天下
3楼-- · 2020-07-09 03:41

You can create new set of key and self signed certificate using filling steps: 1. Creation of key and certificate signing request: openssl req -newkey rsa:2048 -out cert.csr -keyout cert.key 2. Creation of pem openssl x509 -req -signkey cert.key -in cert.csr -out cert.pem

查看更多
登录 后发表回答