简体   繁体   English

如何结合cer和key生成jks文件

[英]How to combine cer and key to generate jks file

I am new to certificates and its conversions from one form to other. 我不熟悉证书及其从一种形式到另一种形式的转换。 I also tried exploring but finding it a bit difficult to interpret exact info. 我也尝试探索,但发现难以解释确切的信息。 I got two files gtcloud.cer (certificate) and gtcloud.key (private key starts with BEGIN_PRIVATE_KEY , ends with END_PRIVATE_KEY ). 我得到了两个文件gtcloud.cer (证书)和gtcloud.key (私钥以BEGIN_PRIVATE_KEY开头,以END_PRIVATE_KEY )。

Now I want to merge these two to generate a single JKS file which I can use in my java application. 现在,我要合并这两个文件,以生成一个可以在我的Java应用程序中使用的JKS文件。

Is there any GUI based software or we have to use openssl for this? 是否有基于GUI的软件,或者我们必须为此使用openssl?

This site explains it. 本网站对此进行了解释。 I was able to use it successfully. 我能够成功使用它。

Summary: Use the following two commands. 摘要:使用以下两个命令。

openssl pkcs12 -export -in [path to certificate] -inkey [path to private key] -certfile [path to certificate ] -out testkeystore.p12
keytool -importkeystore -srckeystore testkeystore.p12 -srcstoretype pkcs12 -destkeystore wso2carbon.jks -deststoretype JKS

Update : If you need to convert you certificate to the pem format, use the following command: 更新 :如果需要将证书转换为pem格式,请使用以下命令:

openssl x509 -inform der -in [path to certificate ] -out myCert.pem

Also, here are some good information about the existing formats: Certificate standards 此外,这是有关现有格式的一些有用信息: 证书标准

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM