是否可以将 SSL 证书从 .key 文件转换为 .pfx? [英] Is it possible to convert an SSL certificate from a .key file to a .pfx?
问题描述
有没有办法将 .key 文件转换为 .pfx 文件?谢谢.
is there a way to convert from a .key file to a .pfx file? thank you.
我只有 .key 文件,但我的托管服务提供商说我可以仅使用该文件将其转换为 .pfx.
I only have the .key file but my hosting provider says that I could convert it to .pfx with just that file.
推荐答案
要检查您的 .key 文件是否包含您需要的一切:
To check if your .key file has everything you need:
#check if file contains a valid certificate:
openssl x509 -text -in file.key
它应该打印出证书详细信息.如果它打印出包含无法加载证书"文本的错误,那么您的文件是不够的.
It should print out certificate details. If it prints an error including the text "unable to load certificate", then your file is not sufficient.
#check if file contains a valid key:
openssl rsa -text -in file.key
openssl dsa -text -in file.key
上述命令之一应打印出有效的密钥详细信息.另一个将给出错误文本expecting an rsa key"或expecting a dsa key".
One of the above commands should print out valid key details. The other will give an error with the text "expecting an rsa key" or "expecting a dsa key".
如果错误文本显示解密错误",则您提供的密码无效,或者文件已损坏.
If the error text says "bad decrypt", you have provided an invalid passphrase, or the file is damaged.
如果错误文本显示Expecting: ANY PRIVATE KEY",则您的文件不够用.
If the error text says "Expecting: ANY PRIVATE KEY", then your file is not sufficient.
如果您有一个密钥和一个与该密钥匹配的证书(以及其他一些可选的证书),那么您就可以将文件转换为 pfx.然后,正如 ISW 所说,这只是
If you got a key, and one certificate which matches the key (and optionally some other certificates), then you have enough to convert the file to a pfx. Then, as ISW said, it's just a matter of
#convert file containing key and certificate(s) to PKCS#12 pfx file.
openssl pkcs12 -export -out file.pfx -in file.key
你就完成了.
这篇关于是否可以将 SSL 证书从 .key 文件转换为 .pfx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!