2011-03-07 133 views

回答

28

.pem格式的證書很可能是ASCII可讀的。它將有一行-----BEGIN CERTIFICATE-----,接着是base64編碼的數據,然後是一行-----END CERTIFICATE-----。之前或之後可能會有其他線路。從支持頁面

36

DER vs. CRT vs. CER vs. PEM Certificates and How To Convert Them

報價:

View 
==== 

Even though PEM encoded certificates are ASCII they are not human 
readable. Here are some commands that will let you output the 
contents of a certificate in human readable form; 

View PEM encoded certificate 
---------------------------- 

Use the command that has the extension of your certificate replacing 
cert.xxx with the name of your certificate 

openssl x509 -in cert.pem -text -noout 
openssl x509 -in cert.cer -text -noout 
openssl x509 -in cert.crt -text -noout 

If you get the folowing error it means that you are trying to view a DER encoded certifciate and need to use the commands in the 「View DER encoded certificate 
below」 

unable to load certificate 
12626:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:647:Expecting: TRUSTED CERTIFICATE View DER encoded Certificate 


View DER encoded Certificate 
---------------------------- 

openssl x509 -in certificate.der -inform der -text -noout 

If you get the following error it means that you are trying to view a PEM encoded certificate with a command meant for DER encoded certs. Use a command in the 「View PEM encoded certificate above 

unable to load certificate 
13978:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1306: 
13978:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=X509 
+0

我正在使用擴展名爲.cer的文件,但文件格式爲.der格式,您的答案可以解決我的問題。 – dpineda 2015-01-26 21:57:05

0

我如何檢查證書文件我是.pem格式

cat文件,並期待用於預先封裝的頭文件和後封裝的頭文件。預封裝的頭文件是-----BEGIN CERTIFICATE----------BEGIN X509 CERTIFICATE-----;並且後封裝的頭文件是-----END CERTIFICATE----------END X509 CERTIFICATE-----

封裝標題在RFC 1421中討論。沒有這些標題中的對象的標準列表或標準列表(如CERTIFICATEX509 CERTIFICATE)。大多數人使用OpenSSL的pem.h頭來獲得對象類型列表。

6

加入OpenSSL到它識別爲PEM格式,必須在Base64編碼,具有以下標題:

-----BEGIN CERTIFICATE----- 

和頁腳:

-----END CERTIFICATE----- 

而且,每個行必須是最大長度爲79個字符。否則,您將收到錯誤:

2675996:error:0906D064:PEM routines:PEM_read_bio:bad base64 decode:pem_lib.c:818: 

注意:PEM標準(RFC1421)規定長度爲64個字符的行。存儲爲單個線A PEM證書可與UNIX命令行實用程序

fold -w 64 
1

參考CRL,CRT,CSR,NEW CSR,PRIVATE KEY, PUBLIC KEY Parser

CRL

-----BEGIN X509 CRL----- 
-----END X509 CRL----- 

CRT

-----BEGIN CERTIFICATE----- 
-----END CERTIFICATE----- 

CSR

被轉換
-----BEGIN CERTIFICATE REQUEST----- 
-----END CERTIFICATE REQUEST----- 

NEW CSR

-----BEGIN NEW CERTIFICATE REQUEST----- 
-----END NEW CERTIFICATE REQUEST----- 

PEM

-----END RSA PRIVATE KEY----- 
-----BEGIN RSA PRIVATE KEY----- 

PKCS7

-----BEGIN PKCS7----- 
-----END PKCS7----- 

PRIVATE KEY

-----BEGIN PRIVATE KEY----- 
-----END PRIVATE KEY----- 
相關問題