SSL certificate expiry is one of the most common causes of website outages. Here's how to check it in Node.js:
import https from "https";
const req = https.request({hostname: "google.com", port: 443, method: "HEAD"}, res => {
const cert = res.socket.getPeerCertificate();
const validTo = new Date(cert.valid_to);
const daysLeft = Math.floor((validTo - new Date()) / 86400000);
console.log(`Issuer: ${cert.issuer.O}`);
console.log(`Expires: ${cert.valid_to}`);
console.log(`Days left: ${daysLeft}`);
console.log(`Status: ${daysLeft < 30 ? "WARNING" : "OK"}`);
});
req.end();
What You Get
- Issuer (Google Trust Services, Let's Encrypt, etc.)
- Expiry date with days remaining
- Subject Alt Names (which domains the cert covers)
- Protocol version (TLS 1.2, 1.3)
- Fingerprint for verification
At Scale
I built an SSL Certificate Checker that processes multiple domains and flags:
- Expired certificates
- Certificates expiring within 30 days
- Self-signed certificates
Free on Apify Store — search knotless_cadence ssl.
Top comments (0)