인증서 종류와 발급: Let's Encrypt 완전 정복
SSL/TLS 인증서는 도메인 소유권을 증명하고 암호화 키를 담는 디지털 문서입니다. 인증서의 종류와 발급 방법을 이해하면 서비스에 맞는 최적의 선택을 할 수 있습니다.
인증서 종류
DV (Domain Validation, 도메인 검증)
도메인 소유권만 확인합니다. 가장 저렴하고 빠르게 발급됩니다.
- 검증 내용: 도메인 소유권 (DNS 레코드 또는 파일 인증)
- 발급 시간: 수 분 ~ 수 시간
- 비용: 무료(Let's Encrypt) ~ 수만 원
- 브라우저 표시: 자물쇠 아이콘
- 적합: 개인 블로그, 스타트업, 내부 서비스
OV (Organization Validation, 조직 검증)
도메인 소유권 + 실제 법인 존재 여부를 확인합니다.
- 검증 내용: 도메인 + 사업자 등록, 법인 실체
- 발급 시간: 1~5 영업일
- 비용: 수십만 원/년
- 브라우저 표시: 자물쇠 아이콘 (인증서에 회사명 포함)
- 적합: 기업 웹사이트, B2B 서비스
EV (Extended Validation, 확장 검증)
가장 엄격한 검증을 거칩니다. 과거에는 주소창에 회사명이 초록색으로 표시됐으나, 현대 브라우저에서는 이 표시가 제거되었습니다.
- 검증 내용: 도메인 + 법인 + 운영 주소 + 전화 확인
- 발급 시간: 5~14 영업일
- 비용: 수십만~수백만 원/년
- 적합: 금융기관, 대형 쇼핑몰
와일드카드 (Wildcard) 인증서
*.example.com 형태로 서브도메인 전체에 사용할 수 있습니다.
*.example.com → shop.example.com, api.example.com, blog.example.com 모두 커버
단, example.com 자체나 sub.sub.example.com은 별도 인증서 필요
멀티도메인 (SAN, Subject Alternative Name)
여러 도메인을 하나의 인증서에 포함합니다.
example.com, example.co.kr, www.example.com → 하나의 인증서
Let's Encrypt: 무료 DV 인증서
Let's Encrypt는 비영리 인증기관으로, 무료 DV 인증서를 자동화된 방식으로 발급합니다. 발급된 인증서의 유효기간은 90일이며, certbot으로 자동 갱신합니다.
Certbot 설치
# Ubuntu 22.04+
sudo apt update
sudo apt install certbot python3-certbot-nginx # Nginx 플러그인
sudo apt install certbot python3-certbot-apache # Apache 플러그인
# CentOS/RHEL
sudo dnf install certbot python3-certbot-nginx
Nginx에서 Let's Encrypt 인증서 발급
방법 1: Nginx 플러그인 (권장)
Certbot이 Nginx 설정을 자동으로 수정합니다.
# 단일 도메인
sudo certbot --nginx -d example.com -d www.example.com
# 이메일 입력, 약관 동의 후 발급 완료
# 인증서 위치: /etc/letsencrypt/live/example.com/
발급 후 Nginx 설정이 자동으로 수정됩니다:
# Certbot이 자동으로 추가한 SSL 설정
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
방법 2: Standalone (Nginx 중지 후)
80 포트를 직접 점유해 인증합니다.
sudo systemctl stop nginx
sudo certbot certonly --standalone -d example.com -d www.example.com
sudo systemctl start nginx
방법 3: Webroot
서비스 중단 없이 발급합니다. Nginx가 실행 중인 상태에서 작동합니다.
# Nginx에 webroot 경로 설정 필요
sudo certbot certonly --webroot \
-w /var/www/html \
-d example.com \
-d www.example.com
# Nginx 설정에 추가 (미리 설정해야 함)
server {
listen 80;
server_name example.com;
location /.well-known/acme-challenge/ {
root /var/www/html;
}
}
와일드카드 인증서 발급 (DNS 인증 필요)
와일드카드는 DNS TXT 레코드로 인증해야 합니다.
sudo certbot certonly --manual --preferred-challenges dns \
-d "*.example.com" -d example.com
# Certbot이 다음 TXT 레코드 추가를 요청합니다:
# _acme-challenge.example.com → "랜덤값"
# DNS 관리 콘솔에서 추가 후 엔터
Apache에서 Let's Encrypt 인증서 발급
# Apache 플러그인으로 자동 발급 + 설정
sudo certbot --apache -d example.com -d www.example.com
# 발급된 인증서 위치
ls /etc/letsencrypt/live/example.com/
# cert.pem ← 서버 인증서
# chain.pem ← 중간 CA 인증서
# fullchain.pem ← 서버 + 중간 CA (이것을 사용)
# privkey.pem ← 개인키
자동 갱신 설정
Let's Encrypt 인증서는 90일마다 갱신이 필요합니다. Certbot이 자동으로 systemd 타이머 또는 cron을 설정합니다.
# 자동 갱신 타이머 확인
sudo systemctl list-timers | grep certbot
# certbot.timer Tue 2024-02-20 00:00:00 UTC 11h ago Mon 2024-02-19 12:00:00 UTC 12h ago certbot.service
# 갱신 테스트 (실제 갱신 없이 시뮬레이션)
sudo certbot renew --dry-run
# 갱신 성공 시 Nginx/Apache 자동 재시작됨
수동 cron 설정 (타이머가 없는 경우)
# /etc/cron.d/certbot
0 0,12 * * * root certbot renew --quiet --post-hook "systemctl reload nginx"
인증서 발급 현황 확인
# 발급된 인증서 목록
sudo certbot certificates
# 출력:
# Found the following certs:
# Certificate Name: example.com
# Domains: example.com www.example.com
# Expiry Date: 2024-05-20 00:00:00+00:00 (VALID: 89 days)
# Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
# Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
# 인증서 상세 정보
openssl x509 -in /etc/letsencrypt/live/example.com/cert.pem -text -noout \
| grep -E "Subject|Not After|DNS"
유료 인증서 적용 방법
기업이나 금융 서비스에서는 Sectigo, DigiCert, GlobalSign 등의 유료 인증서를 사용합니다.
# 1. CSR (Certificate Signing Request) 생성
openssl req -new -newkey rsa:2048 -nodes \
-keyout example.com.key \
-out example.com.csr \
-subj "/C=KR/ST=Seoul/L=Gangnam/O=My Company/CN=example.com"
# 2. CSR을 인증기관에 제출 → 검증 후 인증서 파일 수령
# 3. 수령한 파일 구성:
# example.com.crt ← 서버 인증서
# example.com.ca.crt ← 중간 CA 인증서
# example.com.key ← 개인키
# 4. 인증서 체인 합치기
cat example.com.crt example.com.ca.crt > fullchain.crt
# 5. Nginx/Apache에 적용
인증서 만료 모니터링
# 인증서 만료일 확인
echo | openssl s_client -servername example.com \
-connect example.com:443 2>/dev/null \
| openssl x509 -noout -dates
# notBefore=Jan 15 00:00:00 2024 GMT
# notAfter=Apr 14 23:59:59 2024 GMT
# 만료까지 남은 날 수
echo | openssl s_client -servername example.com \
-connect example.com:443 2>/dev/null \
| openssl x509 -noout -checkend $((30 * 86400)) && \
echo "OK: 30일 이상 유효" || echo "WARNING: 30일 내 만료!"
만료 모니터링 자동화는 pro-tips.md에서 다룹니다.