sitelink1 http://info.ssl.com/article.aspx?id=12149 
sitelink2  
sitelink3  
sitelink4  
extra_vars5  
extra_vars6  

 

Certificates and Encodings

At its core an X.509 certificate is a digital document that has been encoded and/or digitally signed according to RFC 5280.

In fact, the term X.509 certificate usually refers to the IETF’s PKIX Certificate and CRL Profile of the X.509 v3 certificate standard, as specified in RFC 5280, commonly referred to as PKIX for Public Key Infrastructure (X.509).

X509 File Extensions

The first thing we have to understand is what each type of file extension is.   There is a lot of confusion about what DER, PEM, CRT, and CER are and many have incorrectly said that they are all interchangeable.  While in certain cases some can be interchanged the best practice is to identify how your certificate is encoded and then label it correctly.  Correctly labeled certificates will be much easier to manipulat

Encodings (also used as extensions)

  • .DER = The DER extension is used for binary DER encoded certificates. These files may also bear the CER or the CRT extension.   Proper English usage would be “I have a DER encoded certificate” not “I have a DER certificate”.
  • .PEM = The PEM extension is used for different types of X.509v3 files which contain ASCII (Base64) armored data prefixed with a “—– BEGIN …” line.

Common Extensions

  • .CRT = The CRT extension is used for certificates. The certificates may be encoded as binary DER or as ASCII PEM. The CER and CRT extensions are nearly synonymous.  Most common among *nix systems
  • CER = alternate form of .crt (Microsoft Convention) You can use MS to convert .crt to .cer (.both DER encoded .cer, or base64[PEM] encoded .cer)  The .cer file extension is also recognized by IE as a command to run a MS cryptoAPI command (specifically rundll32.exe cryptext.dll,CryptExtOpenCER) which displays a dialogue for importing and/or viewing certificate contents.
  • .KEY = The KEY extension is used both for public and private PKCS#8 keys. The keys may be encoded as binary DER or as ASCII PEM.

The only time CRT and CER can safely be interchanged is when the encoding type can be identical.  (ie  PEM encoded CRT = PEM encoded CER)

Common OpenSSL Certificate Manipulations

There are four basic types of certificate manipulations. View, Transform, Combination , and Extraction

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

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

Transform

Transforms can take one type of encoded certificate to another. (ie. PEM To DER conversion)

PEM to DER

openssl x509 -in cert.crt -outform der -out cert.der

DER to PEM

openssl x509 -in cert.crt -inform der -outform pem -out cert.pem

Combination

In some cases it is advantageous to combine multiple pieces of the X.509 infrastructure into a single file.  One common example would be to combine both the private key and public key into the same certificate.

The easiest way to combine certs keys and chains is to convert each to a PEM encoded certificate then simple copy the contents of each file into a new file.   This is suitable for combining files to use in applications like Apache.

Extraction

Some certs will come in a combined form.  Where one file can contain any one of: Certificate, Private Key, Public Key, Signed Certificate, Certificate Authority (CA), and/or Authority Chain.

번호 제목 글쓴이 날짜 조회 수
공지 [계속 추가중] SBOM 용어 정의 황제낙엽 2025.04.10 5073
공지 [계속 추가중] Keycloak 용어 및 설정 옵션 정의 황제낙엽 2024.02.02 5232
» HOWTO: DER vs. CRT vs. CER vs. PEM Certificates and How To Convert Them 황제낙엽 2019.03.29 1988
39 How to convert a certificate file from .crt to .cer? file 황제낙엽 2019.03.29 4593
38 국내(KOREA) IP 사용 대역 file 황제낙엽 2019.02.21 1391
37 서버 보안 관리를 위한 백업과 점검 절차 황제낙엽 2017.05.30 1106
36 정보 보안 개론 : 네이버 지식백과 황제낙엽 2017.05.19 1250
35 개발용 tomcat 운용시 tomcat-users.xml 의 관리 주의 황제낙엽 2017.04.07 1165
34 윈도우 원격데스크톱(RDP) 접근 이력 조회 file 황제낙엽 2017.04.06 1176
33 SSL, TLS, OpenSSL 관련 황제낙엽 2015.12.31 1298
32 운영 모드 ( Mode of Operation ) 황제낙엽 2013.03.07 1244
31 암호화 알고리즘 스크랩 황제낙엽 2012.08.28 3974
30 미연방 표준 암호 알고리즘 황제낙엽 2010.05.21 1160
29 blowfish java source file 황제낙엽 2010.05.16 990
28 파일 해쉬 알고리즘 CRC 황제낙엽 2009.12.01 745
27 해쉬 알고리즘의 종류 황제낙엽 2009.12.01 762
26 Ajax 보안 관련 문서 (Attacking AJAX Web Applications) file 황제낙엽 2009.02.12 571
25 blowfish 알고리즘 file 황제낙엽 2008.01.22 620
24 OpenSSL을 이용한 보안 통신 API의 설계 및 구현 file 황제낙엽 2007.10.01 478
23 Windows환경에서의 OpenSSL설치 file 황제낙엽 2007.09.28 505
22 OpenSSL Command-Line HOWTO 황제낙엽 2007.09.27 1411
21 Certificate Server의 설치 와 Client인증 황제낙엽 2007.09.27 649