Certificate Expiry Calculator
Calculate days until SSL/TLS certificate expiry and track multiple certificates.
About this tool
SSL and TLS certificates are essential for securing websites and applications, but they expire on a specific date. The Certificate Expiry Calculator helps you track when your certificates will expire, giving you advance notice so you can renew them before they lapse and disrupt your services. This tool is critical for system administrators, DevOps engineers, and website owners who need to manage multiple certificates across their infrastructure.
To use the calculator, simply enter your certificate's expiry date and the tool will instantly show you how many days remain until expiration, along with the exact date and a clear warning status. You can track multiple certificates by entering each one separately, making it easy to create a renewal schedule. The tool works entirely in your browser, so your certificate information never leaves your device.
Certificate expiration is a common cause of service outages, especially for websites, APIs, and email servers. By using this calculator to monitor your certificates proactively, you can plan renewals in advance and avoid costly downtime. The tool is useful for anyone managing SSL/TLS infrastructure, from small businesses with a single certificate to large enterprises with hundreds.
Frequently Asked Questions
Code Implementation
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.