SSL 인증서 만료일 확인 7가지 방법 🌐🔒
| 구분 | 상황 | 명령/경로 | 확인 포인트 |
|---|
| 1 | 브라우저(GUI) | 주소창 자물쇠 클릭 → “인증서(또는 Connection is secure)“ | “유효 기간” 항목 |
| 2 | OpenSSL | `echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates` |
| 3 | openssl + 날짜 계산 | openssl x509 -enddate -noout -in cert.pem | 결과를 date -d 등으로 계산 |
| 4 | curl(간단) | curl -vI https://example.com 2>&1 | grep -i 'expire date' | expire date: |
| 5 | PowerShell (Windows) | powershell $req = [System.Net.ServicePointManager]::FindServicePoint("https://example.com") $req.Certificate.GetExpirationDateString() | 반환 날짜 |
| 6 | Python 스크립트 | ssl·socket 모듈 활용 (예제 아래) | notAfter 필드 |
| 7 | 온라인 툴 | SSL Labs, crt.sh, Why No Padlock 등 | “Valid Until” |
1. 브라우저로 손쉽게 확인
- Chrome/Edge: 주소창 자물쇠 아이콘 클릭 → “연결은 안전함” → “인증서(유효함)” →
유효 기간.
- Firefox: 자물쇠 → “연결 보안” → “더 보기” → “인증서 보기”.
2. OpenSSL 원격 확인 (Linux/macOS)
DOMAIN=example.com
echo | openssl s_client -servername $DOMAIN -connect $DOMAIN:443 2>/dev/null \
| openssl x509 -noout -dates
# 결과
# notBefore=Jun 10 00:00:00 2024 GMT
# notAfter=Sep 8 23:59:59 2024 GMT
• 만료일(notAfter)이 UTC라 국내(KST) 기준 +9 시간 차이 주의.
• 자동 스크립트화:
expiry=$(echo | openssl s_client -servername $DOMAIN -connect $DOMAIN:443 2>/dev/null \
| openssl x509 -noout -enddate | cut -d= -f2)
echo "만료일: $expiry"
echo "D-Day: $(( ($(date -d "$expiry" +%s) - $(date +%s)) / 86400 ))일 남음"
3. 로컬 .pem 파일로 확인
openssl x509 -in /path/to/cert.pem -noout -dates
4. curl만으로 빠르게
curl -vI https://example.com 2>&1 | grep -i "expire date"
# < expire date: 2024-09-08T23:59:59Z
5. PowerShell 예제
$host = "example.com"
$tcp = New-Object Net.Sockets.TcpClient($host,443)
$ssl = New-Object Net.Security.SslStream($tcp.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($host)
$cert = New-Object Security.Cryptography.X509Certificates.X509Certificate2 $ssl.RemoteCertificate
$cert.NotAfter
6. Python 3 스크립트
import ssl, socket, datetime
hostname = 'example.com'
context = ssl.create_default_context()
with socket.create_connection((hostname, 443)) as sock:
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
cert = ssock.getpeercert()
expire = datetime.datetime.strptime(cert['notAfter'], '%b %d %H:%M:%S %Y %Z')
print('만료일:', expire, '| D-Day:', (expire - datetime.datetime.utcnow()).days, '일')
7. 자동 모니터링 꿀팁
• cron에 OpenSSL 스크립트를 등록 후 슬랙/메일 알림 발송
• GitHub Action이나 Zabbix/Prometheus SSL exporter 사용
• Let’s Encrypt 사용 시 certbot renew --dry-run 주기적 실행
자주 묻는 질문(FAQ)
Q1. 사설망 내부 서버도 위 방법으로 확인 가능한가요?
• 로컬 인증서(.pem, .crt)가 있으면 openssl x509로 가능.
• 원격 접속 불가면 파일 복사 후 로컬에서 확인.
Q2. SNI(Server Name Indication)를 꼭 넣어야 하나요?
• 여러 도메인을 동일 IP에 호스팅할 땐 -servername example.com 옵션 필수.
Q3. 만료 임박(예: 30일 이하) 시 조치?
• Let’s Encrypt: certbot renew
• 상용: 재발급 요청 후 웹서버(nginx/apache/etc) 재시작 또는 reload.
🛡️ 주기적으로 확인해 두시면 서비스 장애 걱정 끝!