如何使用openssl从pfx文件中提取私钥? [英] How to extract private key from pfx file using openssl?
问题描述
我一直在寻找这个私钥,以便在Softlayer的添加证书"向导中添加ssl证书,并将其进一步与Local Load Balancer结合使用.
I was looking for this private key to add ssl certificate in Softlayer's "Add Certificate" wizard and to use it further with Local Load Balancer.
我搜索并尝试了以下openssl命令:
I googled and tried following openssl command:
openssl pkcs12 -in filename.pfx -nocerts -out key.pem
但是我最终得到了无效的"RSA PRIVATE KEY".请帮忙.
But I ended up with invalid "RSA PRIVATE KEY". Please help.
推荐答案
您的命令正确,并为您提供了PKCS#8格式的加密私钥.如果您需要未加密私钥,只需添加-nodes
选项:
Your command is correct, and gives you the encrypted private key in PKCS#8 format. If you need the unencrypted private key, just add the -nodes
option:
openssl pkcs12 -in filename.pfx -nocerts -nodes -out key.pem
如果您需要旧RSA格式的私钥,则应使用openssl pkcs8
命令转换给定密钥:
If you need the private key in old RSA format, you should convert the given key with the openssl pkcs8
command:
openssl pkcs8 -in key.pem -out rsakey.pem
有关详细信息,请参阅文档:
See the documentation for details:
- https://www.openssl.org/docs/man1. 1.0/apps/pkcs12.html
- https://www.openssl.org/docs/man1. 1.0/apps/pkcs8.html
- https://www.openssl.org/docs/man1.1.0/apps/pkcs12.html
- https://www.openssl.org/docs/man1.1.0/apps/pkcs8.html
这篇关于如何使用openssl从pfx文件中提取私钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!