如何將 DER 私鑰轉換為 PEM

如何將 DER 私鑰轉換為 PEM

我有一個二進制格式的私鑰。我不確定這是否是 DER 格式,但我需要將其轉換為 PEM。

我使用 openssl 執行以下命令:

openssl rsa -inform DER -outform PEM -in test.key -out test.key

但我收到一個錯誤:

unable to load Private Key
48044:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
48044:error:0D06C03A:asn1 encoding routines:asn1_d2i_ex_primitive:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:713:
48044:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:646:Field=version, Type=PKCS8_PRIV_KEY_INFO
48044:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
48044:error:0D06C03A:asn1 encoding routines:asn1_d2i_ex_primitive:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:713:
48044:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:646:Field=version, Type=RSAPrivateKey
48044:error:04093004:rsa routines:old_rsa_priv_decode:RSA lib:../openssl-1.1.1q/crypto/rsa/rsa_ameth.c:142:
48044:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:1149:
48044:error:0D06C03A:asn1 encoding routines:asn1_d2i_ex_primitive:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:713:
48044:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../openssl-1.1.1q/crypto/asn1/tasn_dec.c:646:Field=version, Type=PKCS8_PRIV_KEY_INFO

如何取得 PEM 金鑰?它有可能不是 DER 密鑰嗎?

相關內容