创建P12证书时OpenSSL私钥错误

时间:2012-11-16 17:12:39

标签: openssl

我正在尝试从一些从OpenSSL创建的现有.der文件创建P12证书。

当我尝试运行以下命令时,出现错误。

C:\Windows\system32>openssl pkcs12 -export -out bundle.p12 -inkey <PATH>/PrivKey.der -in <PATH>/ClientSignedCert.der -certfile <PATH>/CACert.der

我收到的错误:

Loading 'screen' into random state - done
unable to load private key
5688:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_lib
.c:696:Expecting: ANY PRIVATE KEY

我不明白这一点。我给OpenSSL一个私钥(PrivKey.der)。可能是导致此错误的原因是什么?

OpenSSL 1.0.1 2012年3月14日(图书馆:OpenSSL 1.0.1c 2012年5月10日)
Windows 7专业版。

1 个答案:

答案 0 :(得分:1)

根据openssl PKCS12文档,您的-in-inkey和certfile文件必须采用PEM格式。

将证书从DER转换为PEM:

x509 –in ClientSignedCert.der –inform DER –out ClientSignedCert.crt –outform PEM
x509 –in CACert.der –inform DER –out CACert.crt –outform PEM

将密钥从DER转换为PEM:

rsa –in PrivKey.der –inform DER –out PrivKey.key –outform PEM

Openssl PKCS12 documentation

相关问题