首页 文章

我怎么能把pem转换成pfx文件?

提问于
浏览
0

This has me confused

Convert pfx to PEM:
openssl pkcs12 -in certificatename.pfx -out certificatename.pem

这会转储 single 纯文本文件 .

现在我如何将这个纯文本pem转换回pfx?

我看到转换为pfx的唯一命令需要单独文件中的cer和私钥:

Convert CER and Private Key to PFX:    
openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile  cacert.cer

1 回答

  • 1

    虽然我同意这不是真正的编程和可以说是offtopic,但关于(加密)密钥和证书的命令行工具(openssl,keytool,certutil等)的许多类似的Q显然被社区接受(upvoted) - 但我没见过直接解决了这一点 .

    openssl pkcs12 -export 上的不同选项允许您提供不同文件中的部分,但这不是必需的 . 如果您在一个PEM文件中有私钥和证书链,则默认为 pkcs12 [not -export]you can let everything be read from that one file 输出:

    openssl pkcs12 -export -in file -out p12
     # or ONLY IF the privatekey is first in the file
     openssl pkcs12 -export <file -out p12
    

    只要先放私钥,你甚至可以“动态”组合各个部分:

    cat privkey.pem mycert.pem chain.pem | openssl pkcs12 -export -out p12
    

相关问题