2011-03-07 130 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----- 
相关问题