| |
제 목 : openssl로 인증서 정보 살펴보기
작성자 : 좋은진호(truefeel, http://coffeenix.net/ )
작성일 : 2008.12.24(수)
수정일 : 2015.6.16(화) 최근 OpenSSL취약점 관련 참고자료 추가
openssl 명령으로 운영중인 웹서버의 SSL인증서 정보를 살펴볼 수 있다.
| |
# openssl s_client -connect 웹서버:443
| |
imaps(IMAP over SSL, 993포트), pop3s(POP3 over SSL, 995포트)는 포트만 변경하여 다음과 같이 확인한다.
| |
# openssl s_client -connect IMAP서버:993
# openssl s_client -connect POP3서버:995
| |
1. 샘플로 살펴보자.
| |
# echo "" | openssl s_client -connect logins.daum.net:443
CONNECTED(00000003)
---
Certificate chain
0 s:/1.3.6.1.4.1.311.60.2.1.3=KR/2.5.4.15=V1.0, Clause 5.(b)/serialNumber=120-81-47521/C=KR/ST=Seoul/L=Seocho-gu/O=Daum Communications Corp./OU=Pi Lab/OU=Terms of use at www.verisign.com/rpa (c)05/CN=logins.daum.net
... 생략 ...
---
Server certificate
-----BEGIN CERTIFICATE-----
... 생략 ...
-----END CERTIFICATE-----
subject=/1.3.6.1.4.1.311.60.2.1.3=KR/2.5.4.15=V1.0, Clause 5.(b)/serialNumber=120-81-47521/C=KR/ST=Seoul/L=Seocho-gu/O=Daum Communications Corp./OU=Pi Lab/OU=Terms of use at www.verisign.com/rpa (c)05/CN=logins.daum.net
issuer=/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)06/CN=VeriSign Class 3 Extended Validation SSL SGC CA
---
No client certificate CA names sent
---
SSL handshake has read 4843 bytes and written 340 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 1024 bit
SSL-Session:
Protocol : TLSv1
Cipher : DHE-RSA-AES256-SHA
Session-ID:
Session-ID-ctx:
Master-Key: 1160B88DAC017E265FE29B1BE9A85B30FB731B9190A96C06067570E89FEC011EDECA36BB299239959B7DB68A753570E4
Key-Arg : None
Start Time: 1230104266
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
---
DONE
| |
-msg 옵션을 추가하면 전송되는 TLS/SSL 프로토콜까지 살펴볼 수 있다. 이 메시지를 통해서 SSL handshake 과정이 쉽게 파악된다. 아래는 결과중에 메시지 부분만 뽑아낸 것이다. >>> 로 표시 된 것은 Client -> Server로 보낸 메시지이고, <<< 로 표시된 것은 Server -> Client로 보낸 메시지이다.
| |
>>> SSL 2.0 [length 008c], CLIENT-HELLO
<<< TLS 1.0 Handshake [length 002a], ServerHello
<<< TLS 1.0 Handshake [length 10e1], Certificate
<<< TLS 1.0 Handshake [length 018d], ServerKeyExchange
<<< TLS 1.0 Handshake [length 0004], ServerHelloDone
>>> TLS 1.0 Handshake [length 0086], ClientKeyExchange
>>> TLS 1.0 ChangeCipherSpec [length 0001]
>>> TLS 1.0 Handshake [length 0010], Finished
<<< TLS 1.0 ChangeCipherSpec [length 0001]
<<< TLS 1.0 Handshake [length 0010], Finished
>>> TLS 1.0 Alert [length 0002], warning close_notify
| |
[ SSL handshake ]

2. 인증서의 만료일자는 어떻게 살펴볼 수 있을까?
| |
# echo "" | openssl s_client -connect 서버:443 | openssl x509 -noout -dates
notBefore=Oct 14 00:00:00 2008 GMT
notAfter=Oct 30 23:59:59 2009 GMT
| |
notBefore= : '이전에는 없음', 발급일
notAfter= : '이후에는 없음', 만료일
s_client 로 얻은 결과를 다시 'openssl x509' 명령으로 넘겨서 얻은 결과이다. -dates 옵션 대신 -startdate -enddate를 사용해도 만료일을 확인할 수 있다. 이외 -purpose, -subject, -issuer, fingerprint, serial, -hash 등의 옵션으로 인증서의 부분별 정보를 파악할 수 있다.
원격지의 인증서 정보를 자세히 보려면 다음과 같이 -text 옵션을 사용해주면 된다.
| |
# echo "" | openssl s_client -connect 서버:443 | openssl x509 -noout -text
| |
로컬에 있는 인증서 파일을 확인할 때는 어떻게 할까? 위의 openssl x509 -noout -text 형식을 그대로 이용하면 된다.
| |
# openssl x509 -in 인증서파일명 -noout -text
| |
인증서 전체가 아닌 만료일자만 보려면 -text 대신 -dates 를 지정한다. 이외에는 위와 동일하게 옵션을 변경하면 원하는 정보를 얻을 수 있다.
3. 참고자료
* Monitoring SSL certificate expiration date
http://doodlog.blogspot.com/2008/11/monitoring-ssl-certificate-expiration.html
* OpenSSL Command-Line HOWTO
http://www.madboa.com/geek/openssl/
* 커피닉스의 '네트워크(network) > TCP/IP, 프로토콜, 포트' 중 SSL Handshake 자료
http://coffeenix.net/?cata_code=56
* SSL 운영(https)시 도메인기반 Virtual host가 안되는 이유 (글 좋은진호, 2007.9)
http://coffeenix.net/board_view.php?bd_code=1543
* OpenSSL 취약점 정리, Logjam(로그잼)에서 Heartbleed까지 (글 좋은진호, 2015.6)
http://coffeenix.net/bbs/viewtopic.php?p=10318#10318
이 글에는 openssl client로 셋팅 취약점 체크하는 방법 등이 설명되어 있다. 다음과 같은 예로.
$ openssl s_client -connect 서버:443 -ssl3
$ openssl s_client -connect 서버:443 -cipher EXPORT
|