【问题标题】:using OpenSSL to create .pfx file使用 OpenSSL 创建 .pfx 文件
【发布时间】:2010-05-19 20:05:21
【问题描述】:

有人向我提供了一些使用 OpenSSL 创建 .pfx 文件的命令。大多数情况下,我的伙伴从以下位置收集这些信息:Is it possible to convert an SSL certificate from a .key file to a .pfx?

我有以下文件:

  1. 2010certificate.cer
  2. 2010cert_and_key.pem
  3. private_verisign10to11.key

我已尝试同时生成:

openssl pkcs12 -export -out s2010-1.pfx -inkey private_verisign10to11.key -in 2010cert_and_key.pem -certfile 2010certificate.cer
and
openssl pkcs12 -export -out s2010-1.pfx -inkey private_verisign10to11.key -in 2010certificate.cer -certfile 2010cert_and_key.pem 

在这种情况下没有报错,但是当我尝试查看或导入生成的文件 s2010-1.pfx 时,Protecle 说它无法打开它。 Keytool 说:

keytool -import -file s2010-1.pfx x -keystore cacerts -alias fqdn -storepass <.pfx's pass word>
keytool error: java.lang.Exception: Input not an X.509 certificate

我假设问题出在 .pfx 生成,但我真的不知道如何测试它,直到 keytool 命令。任何关于从这里做什么的建议都会很棒。

【问题讨论】:

标签: openssl pfx keytool


【解决方案1】:

尝试使用TinyCA 打开您的 3 个文件中的每一个,因为它们可以是其扩展名所说的其他内容,特别是 .pem 文件。然后使用 TinyCA 导出密钥;有一个消息窗口显示 openssl 命令和该命令的输出。

【讨论】:

    【解决方案2】:

    问题是因为keytool -importcert(Java -import)只支持导入 x509 证书。

    将 PKCS12(有时以 .pfx 文件提供)导入 Java .jks 文件,包括cacerts

    keytool -importkeystore -srckeystore my.pfx -srcstoretype PKCS12 -srcstorepass <mysecret> -destkeystore cacerts -deststoretype JKS  -deststorepass changeit
    

    【讨论】:

      猜你喜欢
      • 2016-08-10
      • 1970-01-01
      • 2018-10-06
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2010-10-08
      • 2019-07-28
      • 1970-01-01
      相关资源
      最近更新 更多