Retrieves and validates certificate information for a given host.
Checks performed: expiration, not-yet-valid, hostname verification, self-signed detection, certificate structure, and cryptographic security (key size, signature algorithm).
Limitations: This function does not perform OCSP or CRL revocation checking. A certificate that has been revoked by its CA will still appear as valid: true if it passes all other checks. For revocation checking, use a dedicated PKI library.
valid: true
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("example.com");console.log(`Valid: ${info.valid}, Days left: ${info.daysLeft}`); Copy
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("example.com");console.log(`Valid: ${info.valid}, Days left: ${info.daysLeft}`);
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("expired.badssl.com");if (!info.valid) { console.log(`Errors: ${info.errors.join(", ")}`);} Copy
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("expired.badssl.com");if (!info.valid) { console.log(`Errors: ${info.errors.join(", ")}`);}
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("example.com", { port: 8443 }); Copy
import { getCertificateInfo } from "sslko";const info = await getCertificateInfo("example.com", { port: 8443 });
Will return an object with valid: false and an error message.
valid: false
Retrieves and validates certificate information for a given host.
Checks performed: expiration, not-yet-valid, hostname verification, self-signed detection, certificate structure, and cryptographic security (key size, signature algorithm).
Limitations: This function does not perform OCSP or CRL revocation checking. A certificate that has been revoked by its CA will still appear as
valid: trueif it passes all other checks. For revocation checking, use a dedicated PKI library.