PKI와 인증서 관리
PKI 완벽 가이드
1. PKI (Public Key Infrastructure)
공개키 암호화를 위한 인프라
CA (Certificate Authority)
↓ 발급
인증서
↓ 포함
공개키 + 신원 정보 + CA 서명
2. 인증서 구조
버전: V3
일련번호: 123456
서명 알고리즘: RSA-SHA256
발급자: CN=Let's Encrypt
유효기간: 2024-01-01 ~ 2024-12-31
주체: CN=example.com
공개키: MIIBIjANBgkqhkiG9w0...
확장:
- Subject Alternative Names: example.com, www.example.com
- Key Usage: Digital Signature, Key Encipherment
CA 서명: (RSA 서명)
3. 인증서 체인
Root CA (자체 서명)
↓
Intermediate CA
↓
Server Certificate (example.com)
검증 과정
1. Server Certificate의 서명을 Intermediate CA 공개키로 검증
2. Intermediate CA의 서명을 Root CA 공개키로 검증
3. Root CA는 신뢰할 수 있는 CA 목록에 있는지 확인
4. Let's Encrypt
# Certbot 설치
sudo apt install certbot python3-certbot-nginx
# 인증서 발급
sudo certbot --nginx -d example.com -d www.example.com
# 자동 갱신
sudo certbot renew --dry-run
# Cron job
0 0 * * * certbot renew --quiet
5. 인증서 생성 (OpenSSL)
# 개인키 생성
openssl genrsa -out private.key 2048
# CSR (Certificate Signing Request) 생성
openssl req -new -key private.key -out request.csr
# 자체 서명 인증서 (개발용)
openssl x509 -req -days 365 -in request.csr \
-signkey private.key -out certificate.crt
# 인증서 확인
openssl x509 -in certificate.crt -text -noout
6. mTLS (Mutual TLS)
클라이언트도 인증서 제시
server {
listen 443 ssl;
ssl_certificate /path/to/server.crt;
ssl_certificate_key /path/to/server.key;
# 클라이언트 인증서 요구
ssl_client_certificate /path/to/ca.crt;
ssl_verify_client on;
}
결론
PKI는 인터넷 보안의 기반입니다.
핵심:
- CA: 신뢰할 수 있는 제3자
- 인증서 체인: 신뢰 전파
- Let's Encrypt: 무료 인증서