-1

我想创建一个 .p12 或 .pfk 文件。我有以下文件:

  • xx.cer
  • xx.p7b
  • xx.pem
  • xx.pkcs8

我尝试了很多 openssl 命令,但我只能创建一个零字节的 .p12 文件。

我执行的 openssl 命令示例:

openssl pkcs12 -export -inkey xx.pem -out xx.p12
4

2 回答 2

0

I don't know what is in xx.pem file and what is in xx.pkcs8. Private key should be in one (or both?) of these files. I will assume that the private key is in xx.pem file. Then the command to make a p12 file should be:

openssl pkcs12 -export -inkey ./xx.pkcs8 -in ./xx.pem -out ./xx.p12

Openssl will promt you to add a password to p12 file but when typing there will be no asterisks on the screen. Don't worry just type the password. This p12 file will contain private key and corresponding certificate. It will not include chain certificates which could be in xx.p7b file.

于 2014-08-15T09:38:28.513 回答
0

我将 pkcs8 文件转换为 pem 和 b64,并更新了页眉和页脚。当我启动如下命令时,出现此错误:

命令:

openssl pkcs12 -export -inkey ./xx.pem -in ./xx.cer -out ./xx.p12
openssl pkcs12 -export -inkey ./xx.b64 -in ./xx.cer -out ./xx.p12

结果 :

unable to load private key
58163:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/asn1/tasn_dec.c:1315:
58163:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/asn1/tasn_dec.c:827:
58163:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/asn1/tasn_dec.c:747:Field=version, Type=RSA
58163:error:0D09A00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/asn1/d2i_pr.c:99:
58163:error:0907B00D:PEM routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/pem/pem_pkey.c:125:
于 2014-08-19T13:08:31.797 回答