我有一个 .key 文件,当我运行
openssl rsa -text -in file.key
时,我得到以下结果:
unable to load Private Key
140000419358368:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: ANY PRIVATE KEY
另外,我有一个.cer文件,当我运行
openssl x509 -text -in file.cer
我得到以下结果:
unable to load certificate
140387178489504:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
但是如果像这里所指出的那样,我运行以下命令:
openssl x509 -text -inform DER -in file.cer
我会得到:
Certificate:
Data:
Version: 3 (0x2)
Some more information
...
-----BEGIN CERTIFICATE-----
MIIEdDCCA1ygAwIBAgIUMjAwMDEwMDAwMDAxMDAwMDU4NjcwDQYJKoZIhvcNAQEF
...
-----END CERTIFICATE-----
但是这似乎对密钥无效,因为当我运行
openssl rsa -text -inform DER -in aaa010101aaa__csd_10.key
时,我得到:
unable to load Private Key
140004844304032:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1337:
140004844304032:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:tasn_dec.c:849:
140004844304032:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:769:Field=version, Type=RSA
140004844304032:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib:rsa_ameth.c:115:
140004844304032:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1337:
140004844304032:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:tasn_dec.c:849:
140004844304032:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:769:Field=version, Type=PKCS8_PRIV_KEY_INFO
我如何获取私钥及其证书?
iconv -c -f UTF8 -t ASCII cert.key > cert2.key
来进行转换。 - a2f0-f UTF-8
而不是-f UTF8
。 - Saitesiconv --list | grep UTF
。 - a2f0