Home / Guides / How to Check SSL Certificate Expiry

Updated

How to Check SSL Certificate Expiry (One Site or Hundreds)

Run echo | openssl s_client -connect apify.com:443 -servername apify.com | openssl x509 -noout -enddate to read the certificate's expiry date, and add -checkend 2592000 to fail when it expires within 30 days. In bulk, Plainprobe Domain Intelligence returns issuer, validTo and daysRemaining per domain as JSON: on 2 December 2026 apify.com had an Amazon wildcard certificate valid to 2027-01-16, 45 days left.

1. One site with openssl

echo | openssl s_client -connect apify.com:443 -servername apify.com 2>/dev/null \
  | openssl x509 -noout -enddate -issuer -subject

-servername sends SNI, so you get the certificate of that host and not the server's default one. notAfter is the expiry date in UTC.

2. Alert before it expires

echo | openssl s_client -connect apify.com:443 -servername apify.com 2>/dev/null \
  | openssl x509 -noout -checkend 2592000 || echo "expires within 30 days"

-checkend takes seconds and exits with code 1 when the certificate will have expired by then: put it in a daily cron job or a CI step.

3. Common pitfalls

4. Hundreds of domains as JSON

Plainprobe Domain & Tech Stack Intelligence returns, per domain, ssl.issuer, validFrom, validTo, daysRemaining, wildcard and protocol, with RDAP domain expiry, DNS, SPF and DMARC in the same record, at $0.003 per domain; invalid and non-existent domains are free. Its monitor mode reports certificates expiring soon. Real output for apify.com on 2 December 2026: {"issuer": "Amazon", "subject": "*.apify.com", "validTo": "2027-01-16T23:59:59.000Z", "daysRemaining": 45, "protocol": "TLSv1.3"}. See also How to look up a domain with RDAP.

Limits to keep in mind

FAQ

How do I check when an SSL certificate expires?

Run echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate. The notAfter line is the expiry date in UTC.

How do I alert before a certificate expires?

openssl x509 -checkend 2592000 exits with code 1 when the certificate expires within 30 days (2,592,000 seconds), so a cron job or CI step can fail on it.

Why does my check show a different certificate than my browser?

Without -servername the server may return its default certificate instead of the one for your host (SNI). A corporate TLS-inspecting proxy also replaces the certificate: run the check from a network without inspection.

How many days do certificates last now?

Under CA/Browser Forum ballot SC-081, the maximum lifetime of public TLS certificates fell from 398 to 200 days on 15 March 2026, and drops to 100 days in March 2027 and 47 days in March 2029, so expiry checks matter more every year. Let's Encrypt certificates last 90 days.

Related tool