コンテンツへスキップ
🛠️ToolsShed

証明書有効期限計算機

SSL/TLS証明書の有効期限までの日数を計算し、複数の証明書を追跡します。

このツールについて

SSLおよびTLS証明書はウェブサイトとアプリケーションのセキュリティに不可欠ですが、特定の日付に期限切れになります。証明書失効日計算機は、証明書がいつ失効するかを追跡し、期限切れが発生してサービスが中断する前に更新するための事前通知を提供します。このツールは、インフラストラクチャ全体の複数の証明書を管理する必要があるシステム管理者、DevOpsエンジニア、およびウェブサイト所有者にとって重要です。

計算機を使用するには、証明書の失効日を入力するだけで、ツールが残り日数と正確な日付、明確な警告ステータスをすぐに表示します。各証明書を別々に入力することで複数の証明書を追跡でき、更新スケジュールを簡単に作成できます。このツールはブラウザ完全動作するため、証明書情報がデバイスを離れることはありません。

証明書の失効はウェブサイト、API、メールサーバーの一般的なサービス停止原因です。この計算機を使用して証明書を積極的に監視することで、更新を事前に計画し、高額なダウンタイムを回避できます。このツールは単一の証明書を持つ小規模企業から数百の証明書を持つ大企業まで、SSLTLSインフラストラクチャを管理する誰もが活用できます。

よくある質問

コード実装

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.