How to extract private key from pfx file using openssl?

倖福魔咒の 提交于 2019-12-03 10:45:02

问题


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.

I googled and tried following openssl command:

openssl pkcs12 -in filename.pfx -nocerts -out key.pem

But I ended up with invalid "RSA PRIVATE KEY". Please help.


回答1:


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

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://stackoverflow.com/questions/16397858/how-to-extract-private-key-from-pfx-file-using-openssl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!