Updated
How to Check SSL Certificate Expiry (One Site or Hundreds)
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
- TLS-inspecting proxies replace the certificate with their own: a check from a corporate network or a sandbox can show the proxy's expiry date, not the site's.
- www and apex can use different certificates: check both hosts.
- Timeouts: wrap the command in
timeout 15so one dead host does not block a batch.
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
- A valid date does not mean a valid chain: check the issuer and hostname match too.
- Only check hosts you are allowed to probe; one TLS handshake per host per day is plenty.
- An expired certificate takes the site down for visitors: see how to check if a website is down for what that failure looks like.
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.