본문으로 건너뛰기
🛠️ToolsShed

인증서 만료일 계산기

SSL/TLS 인증서 만료까지의 일수를 계산하고 여러 인증서를 추적합니다.

이 도구 소개

SSL 및 TLS 인증서는 웹사이트와 애플리케이션을 보호하는 데 필수적이지만 특정 날짜에 만료됩니다. 인증서 만료 계산기는 인증서가 언제 만료될지 추적하여 만료되기 전에 갱신할 수 있도록 미리 알려줍니다. 이 도구는 인프라 전체에서 여러 인증서를 관리해야 하는 시스템 관리자, DevOps 엔지니어 및 웹사이트 소유자에게 필수적입니다.

계산기를 사용하려면 인증서의 만료 날짜를 입력하면 남은 일 수, 정확한 날짜 및 명확한 경고 상태를 즉시 표시합니다. 각 인증서를 개별적으로 입력하여 여러 인증서를 추적할 수 있으므로 갱신 일정을 쉽게 작성할 수 있습니다. 이 도구는 브라우저에서 완전히 작동하므로 인증서 정보가 사용자 기기를 떠나지 않습니다.

인증서 만료는 웹사이트, API 및 이메일 서버에서 흔한 서비스 중단 원인입니다. 이 계산기를 사용하여 인증서를 적극적으로 모니터링하면 갱신을 미리 계획하고 비용이 많이 드는 다운타임을 피할 수 있습니다. 이 도구는 단일 인증서를 가진 소규모 기업부터 수백 개의 인증서를 가진 대규모 기업까지 SSL/TLS 인프라를 관리하는 누구나 사용할 수 있습니다.

자주 묻는 질문

코드 구현

import ssl
import socket
from datetime import datetime, timezone

def get_cert_expiry(hostname: str, port: int = 443) -> dict:
    """Fetch TLS certificate expiry info for a hostname."""
    context = ssl.create_default_context()
    with socket.create_connection((hostname, port), timeout=5) as sock:
        with context.wrap_socket(sock, server_hostname=hostname) as ssock:
            cert = ssock.getpeercert()

    not_after = datetime.strptime(cert['notAfter'], '%b %d %H:%M:%S %Y %Z')
    not_after = not_after.replace(tzinfo=timezone.utc)
    now = datetime.now(timezone.utc)
    days_remaining = (not_after - now).days

    return {
        "hostname": hostname,
        "expires": not_after.strftime('%Y-%m-%d'),
        "days_remaining": days_remaining,
        "status": "expired" if days_remaining < 0
                  else "critical" if days_remaining < 14
                  else "warning" if days_remaining < 30
                  else "good",
        "subject": dict(x[0] for x in cert.get('subject', [])),
        "issuer": dict(x[0] for x in cert.get('issuer', [])),
    }

# Example
result = get_cert_expiry("example.com")
print(f"Expires: {result['expires']}")
print(f"Days remaining: {result['days_remaining']}")
print(f"Status: {result['status']}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.