如何从密钥库导出.key和.crt [英] How to export .key and .crt from keystore

查看:236
本文介绍了如何从密钥库导出.key和.crt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在开发机器上构建android应用程序时,我需要为应用程序提供SSL证书,因此我为Tomcat生成了一个带keytool的密钥库。我从密钥库中提取了证书并将其放入.bks以使用android,一切顺利。

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.

现在我们必须将所有服务器端代码转移到所需的服务器Apache HTTP和Tomcat。 Apache HTTP SSL需要.key和.crt文件,我找不到从密钥库导出.key和.crt文件的方法

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

任何人都可以帮忙吗?我发现你可以从.pem生成.crt

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

但我怎么能得到.key文件?

But how can i get .key file?

推荐答案

Keytool(JDK中提供)允许您将证书导出到文件:

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

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

要导出常规键,您应该使用-importkeystore命令(惊讶):

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

keytool -importkeystore -srckeystore [keystore] -destkeystore [target-keystore] -deststoretype PKCS12

这篇关于如何从密钥库导出.key和.crt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆