Repository navigation
Description
Problem
Certificates still expire in production. Auto-renewal breaks quietly (a DNS change, a moved load balancer, a renewal hook that stopped running) and the first sign is a full-page browser warning. A few related failures are just as common and just as invisible from the audited URL:
- The certificate covers
example.combut notwww.example.com, so everyone who typeswww.gets a warning before the redirect to the apex can happen. - The server sends the leaf certificate without its intermediate. Desktop Chrome often fetches the missing intermediate itself and shows the page; curl, many API clients, crawlers and some mobile browsers refuse it.
- A staging certificate (self-signed, or for the wrong host) gets deployed to production.
squirrel does not look at the certificate. security/https (packages/rules/src/security/https.ts) only checks that the page URL starts with https:. When the handshake fails outright, the crawl fails with a generic TLS failure reason ("check its expiry, hostname coverage, and that the full chain is served") that does not say which of those it was. Nothing warns before expiry.
Proposal
New rule security/tls-certificate, site scope, one TLS handshake per audited host (plus the www/apex variant, below). It runs in the CLI first.
- Error: the certificate has expired.
- Error: expires within 7 days (
error_days, default 7). - Warn: expires within 30 days (
warn_days, default 30). - Error: the certificate does not cover the audited hostname.
- Error: the certificate is self-signed or chains to an untrusted root.
- Error: the chain is incomplete (the server does not send the intermediate needed to reach a trusted root).
- Warn: the www/apex variant of the audited host (
www.example.comforexample.com, and the reverse) resolves and answers on 443, but its certificate is invalid for that name. Checked only when the variant resolves, since many sites serve only one. - Warn: a weak key: RSA under 2048 bits.
- Pass detail: issuer, expiry date and days remaining, so the report shows them even when nothing is wrong.
Not reported:
- Plain
http:sites:security/httpscovers them. - Hosts on a private network or
localhost, which usually run a dev certificate (sameskipOnPrivateTargetbehaviour assecurity/https).
When the crawl itself fails on a TLS error, the failure message should name the specific cause found by the same handshake (expired on a date, hostname not covered, incomplete chain, self-signed) instead of the generic list.
Phase 2: legacy protocol versions
Reporting a server that still accepts TLS 1.0 or 1.1 is a separate, later step. It needs a client that can offer only those versions, and the Bun TLS client does not do that today (see Notes).
Notes
- Implementation (CLI): the CLI is a Bun standalone binary, and Bun implements
node:tls. Checked against Bun 1.3.14:tls.connect({ host, servername, rejectUnauthorized: false })followed bygetPeerCertificate()returnsvalid_to,subjectaltname,bitsandissuer, andauthorizationErrordistinguishes the cases above:CERT_HAS_EXPIRED,ERR_TLS_CERT_ALTNAME_INVALID,DEPTH_ZERO_SELF_SIGNED_CERT, andUNABLE_TO_VERIFY_LEAF_SIGNATUREfor a missing intermediate (verified against the badssl.com test hosts). - Bun limits found while checking:
getPeerCertificate(true)does not populateissuerCertificate, so the chain cannot be walked; detect an incomplete chain fromauthorizationErrorinstead.minVersion/maxVersionare ignored (asking for TLS 1.1 only still negotiated TLS 1.3), which is why legacy-protocol detection is phase 2. - No existing socket code: the engine has no raw TLS or socket usage today; every request goes through
fetch. This adds the first one, so keep it in one small module with a timeout and a single connection per host. - Hosted audits:
fetchin Workers-style runtimes exposes no peer certificate. The rule is CLI/local-first; where no TLS socket API is available it reports "not checked", never "pass". A hosted implementation is a follow-up. - Category: security. New rule: broken scripts, stylesheets and fonts (no render needed) #703 lists certificate expiry as a later candidate for a Reliability category; expiry is arguably reliability, but hostname, chain, self-signed and key strength are security properties, and splitting one handshake across two categories would confuse more than it helps.
- Cost: one or two handshakes per audit, no HTTP requests.
- False-positive risk: low for the certificate facts. The www/apex check only runs when the variant resolves and accepts a connection.
Acceptance Criteria
- A CLI audit of a host whose certificate expires in 20 days produces a warning showing the expiry date and days remaining; 5 days produces an error; an expired certificate produces an error
-
warn_daysanderror_daysoptions change the thresholds (fixture:warn_days = 60makes a 45-day certificate warn) - A certificate that does not cover the audited hostname produces an error naming the hostname and the names the certificate does cover
- A self-signed certificate produces an error that says self-signed
- A server that omits its intermediate certificate produces an incomplete-chain error
- Auditing
example.comwherewww.example.comresolves and serves a certificate that does not cover it produces a warning namingwww.example.com; when the variant does not resolve, nothing is reported - An RSA key under 2048 bits produces a warning
- A valid certificate produces a pass that shows the issuer and expiry date
- Auditing
localhostor a private-network host skips the rule - In an environment without a TLS socket API, the rule reports "not checked", not pass or fail
- When the crawl fails on a TLS error, the failure message names the specific cause (expired, hostname, chain, self-signed)
- Tests use local TLS fixtures (generated certificates), not live third-party hosts
- The rule has a docs page under
docs/rules/security/, including its options
Activity
test(rules): exercise security/tls-certificate through the audit stag…
test(audit-engine): bump canonical golden counts for security/tls-cer…
feat(rules): add content/common-misspellings with an MIT word list #712
nc9 commentedon Oct 13, 2026
Note: commit f55626e (pub#720, content/common-misspellings) references this issue by mistake in its subject; it belongs to #709. This issue (TLS certificate rule) is still open and unaffected.
feat(rules): add security/tls-certificate for expiry, hostname, chain…
fix(rules,crawler,cli): inject the TLS handshake from the CLI behind …
feat(rules): add security/tls-certificate for expiry, hostname, chain…
fix(rules,crawler,cli): inject the TLS handshake from the CLI behind …
fix(cli): --offline checks the audited host's certificate only, not i…
feat(rules): add security/tls-certificate for expiry, hostname, chain…
fix(rules,crawler,cli): inject the TLS handshake from the CLI behind …
fix(cli): --offline checks the audited host's certificate only, not i…
fix(cli): the TLS probe compares the audited host without its root dot …
fix(utils): the SAN entry parser uses trim and a plain prefix match, …
feat(rules): add security/tls-certificate for expiry, hostname, chain…