简体   繁体   English

将BIN格式的证书转换为X509格式

[英]Convert certificate in BIN format to X509 format

I have read this good article on running tomcat in https and implemented it. 我已经阅读了这篇关于在https中运行tomcat的好文章并实现了它。

http://techtracer.com/2007/09/12/setting-up-ssl-on-tomcat-in-3-easy-steps/ http://techtracer.com/2007/09/12/setting-up-ssl-on-tomcat-in-3-easy-steps/

It is working fine and my tomcat is running in https mode. 它工作正常,并且tomcat在https模式下运行。

But the problem is i got the certificate in BIN format . 但是问题是我得到了BIN格式的证书。 I need it in X509 format so that i can use it as an raw resource for my Android project 我需要X509格式,以便可以将其用作Android项目的原始资源

I have used java keytool to create it.Can i use OpenSSL to convert it into X509 Format or java keytool is sufficient? 我已经使用Java Keytool来创建它,我可以使用OpenSSL将其转换为X509格式还是Java Keytool就足够了?

I am new to this securities stuff. 我是这种证券的新手。

Please point me in the right direction and clear my doubts. 请指出正确的方向,并清除我的疑问。

I think keytool already handles certificates in X509 format only. 我认为keytool已经可以处理X509格式的证书。 You should have generated .keystore file. 您应该已经生成了.keystore文件。 You can export certificate from it using command: 您可以使用以下命令从中导出证书:

keytool -export -alias mycert -keystore mykeystore.bin -file certificatefile.cer keytool-导出-alias mycert -keystore mykeystore.bin-文件certificatefile.cer

Yes of course, you can use OpenSSL to convert the certificate and keys to and from the following formats 是的,当然可以,您可以使用OpenSSL在以下格式之间来回转换证书和密钥:

  • Standard PEM 标准PEM
  • DER / Binary DER /二进制
  • PKCS#7 (aka P7B) PKCS#7(又名P7B)
  • PKCS#12 (aka PFX) PKCS#12(又名PFX)

In your case, given a private key file and digital certificate in standard PEM, convert them both to pkcs12 format using the following steps: 对于您的情况,给定标准PEM中的私钥文件和数字证书,请使用以下步骤将它们都转换为pkcs12格式:

Step 1: Convert the PEMs to a single PKCS12 file 步骤1:将PEM转换为单个PKCS12文件

    OpenSSL> pkcs12 -export -in CE_cert.cer -inkey CE_prv_key_PEM.key -out
pkcs12_KeyStore.p12 -name ce_cert_prv_key

Heres the doc for OpenSSL PKCS12 command. 这是OpenSSL PKCS12命令的文档。

Step 2: Import the PKCS12 file created in step 1 into the new JKS 步骤2:将步骤1中创建的PKCS12文件导入到新的JKS中

C:\>keytool -importkeystore -srckeystore pkcs12_KeyStore.p12 -srcstoretype pkcs12 -srcstorepass somepass -srcalias ce_cert_prv_key -destk
eystore path/to/JavaKeyStore_KS.jks -deststoretype jks -deststorepass somepass -destkeypass somepass

Now after having the certificate and private key in the JKS format, you can use this JSK key store in Tomcat. 现在,在拥有JKS格式的证书和私钥之后,您可以在Tomcat中使用此JSK密钥存储。

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

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