squirrelscan
GitHub

TLS certificate: expiry, hostname, chain and key checks

A certificate that expires, does not cover the hostname, or is missing its intermediate breaks the page for some visitors. squirrel reads the certificate once per host and names each problem.

What the certificate protects

A TLS certificate binds a hostname to a public key, and a browser or API client refuses to talk to the server unless that binding checks out. Four things go wrong in production, and each one shows up to visitors as a warning page while the site looks fine from the server:

  • Expiry. Automatic renewal breaks quietly, after a DNS change, a moved load balancer or a renewal hook that stopped running. The first sign is a full-page browser warning.
  • Hostname coverage. The certificate covers example.com but not www.example.com, so everyone who types www. sees a warning before any redirect can happen.
  • Chain. The server sends the leaf certificate without the intermediate that links it to a trusted root. Desktop Chrome often fetches the missing intermediate itself, so the page loads for you. curl, many API clients, crawlers and some mobile browsers refuse it.
  • Staging certificates. A self-signed or staging certificate reaches production.

What squirrel checks

The rule makes one TLS handshake with the audited host and reads the certificate the server presents. It does not send an HTTP request. When the audited host is a registrable domain or its www. name, the rule also handshakes with the other one (www.example.com for example.com, and the reverse) on the same port. Any other subdomain, such as blog.example.com, has no counterpart, and on a shared platform domain the counterpart stays inside the site’s own name (acme.pages.dev and www.acme.pages.dev).

Expiry warning window

Automated CAs renew a certificate at about a third of its lifetime left: certbot and Let’s Encrypt at 30 days of 90, and the managed certificates on Cloudflare, Google and Vercel the same way. A fixed 30-day warning therefore fired on healthy, auto-renewing certificates for a day or so before every routine renewal, and certificate lifetimes are shrinking (200 days from March 2026, then 100, then 47 by 2029), so a fixed window would flag a growing share of valid certificates.

By default the warning waits until a renewal is overdue. With the certificate’s lifetime L (notAfter - notBefore, rounded to whole days, so Let’s Encrypt’s 90 days less a second reads 90), the check warns when the days remaining are at most L / 3 - margin, rounded down, where the margin is 14 days or 15% of L, whichever is less. The error threshold is 7 days, or a tenth of L (at least one day) for a certificate under 70 days, so a short-lived certificate neither fails on its third day nor loses its warning step. Neither is ever below the other: the warning window is at least the error threshold.

LifetimeWarns atErrors at
365 days107 days or fewer7 days or fewer
200 days527
90 days167
47 days84
30 days53
10 days or less11

A 90-day certificate with 28 days left passes, with 10 days left it warns, and with 5 days left it fails. The check details carry the windows that were used (warnDays, errorDays) and whether each came from the lifetime or from an option. If the lifetime cannot be read the warning window is 30 days. Setting warn_days or error_days replaces the derived value with a fixed number of days.

Before each handshake, squirrel resolves the name once and checks the address, as it does for the crawl’s own hosts. It never connects to a link-local or cloud metadata address. The www or apex counterpart of a public site must also resolve to a public address. The connection goes to the address that was checked, with the hostname sent for SNI and verification.

It emits these checks:

  • tls-certificate-expiry judges the date. It fails when the certificate has expired, when it is not yet valid, or when it expires within error_days. It warns when it expires within warn_days or, when that is not set, within the last third of the certificate’s lifetime less a 14-day renewal margin (see Expiry warning window). Otherwise it passes, and the message shows the issuer, the expiry date and the days remaining.
  • tls-certificate-hostname fails when the certificate does not cover the audited hostname. The message names the hostname and the names the certificate does cover. A wildcard such as *.example.com covers one label.
  • tls-certificate-chain fails in three cases. A self-signed certificate says so. A server that omits its intermediate reports an incomplete chain when the runtime reports a missing leaf signature, which is how squirrel’s runtime reports it. A chain that does not verify under the verification error UNABLE_TO_GET_ISSUER_CERT_LOCALLY gets a different message: an intermediate may be missing, or the root is not trusted. The check cannot tell those two apart, because the runtime does not expose the served chain. To see which one it is, run openssl s_client -connect HOST:443 -servername HOST -showcerts and look at how many certificates the server sends.
  • tls-certificate-key warns when the leaf’s public key type is not in key_types (a DSA key warns by default) or its size is below the minimum for its type (rsa_min_bits, ecdsa_min_bits, dsa_min_bits). The message names the key: RSA 1024 bits, ECDSA P-256, Ed25519, DSA 1024 bits. Ed25519 has no size to judge. The runtime squirrel audits with cannot complete a handshake with a certificate whose key is Ed25519, Ed448, DSA, RSA-PSS, P-521 or secp256k1, so live those sites are not checked and these key names and the key_types allow-list for them can only show on a runtime that can read such a certificate; RSA and ECDSA P-256 and P-384 keys are judged live.
  • tls-certificate-signature warns when the leaf certificate is signed with SHA-1, MD5, MD4 or MD2 (reject_weak_signature). Only the leaf is judged: the runtime does not expose the rest of the chain.
  • tls-certificate-protocol warns when the server negotiated a protocol below min_tls_version. squirrel’s runtime offers its best protocol, cannot be told to offer an older one, and refuses to speak below TLS 1.2. A server that only speaks TLS 1.0 or 1.1 therefore ends the handshake and is not checked, never a protocol warning; a server that also accepts TLS 1.0 negotiates its best (TLS 1.2 or 1.3) and passes. In practice the check can only fire when min_tls_version is TLSv1.3 and the server tops out at TLS 1.2; with the default TLSv1.2 it cannot.
  • tls-certificate-www warns when the www or apex counterpart resolves and answers on the same port, but its certificate is not valid for that name. A counterpart that does not resolve, or does not answer, reports nothing.

The check for expiry always runs when the handshake succeeds, so a valid site gets a pass that shows its issuer and expiry date.

The runtime reports only the first verification error it meets, and expiry and the hostname come before the chain. An expired certificate that is also self-signed, or missing its intermediate, reports as expired only, so fixing one problem can reveal the next. Run the audit again after each fix.

When the handshake cannot be made, the rule reports not checked: a skipped check with the reason, which every report lists under “Not checked” and the JSON report lists in notChecked, never as a pass or a failure for a certificate it did not read. The handshake runs in the squirrel CLI. With --offline, only the audited host is contacted, so the counterpart is not checked. squirrel analyze reads the certificate the site serves when it runs, not the one at the time of the crawl. It is also not checked when the audited host’s address is refused by the check above, or when the host does not answer.

When the start URL’s certificate is broken

If the audited URL itself fails its TLS handshake because of its certificate (an expired or not-yet-valid certificate, a name it does not cover, a self-signed certificate, a chain that does not verify to a trusted root), no page can be fetched, so no audit runs and there is no score. squirrel audit still writes a report in the format you asked for, with status unreachable and the exit code 5, and that report carries the rule’s result: a security/tls-certificate failure with the cause. One handshake names the cause, the same one the crawl uses for a failed page: certificate has expired on 2026-01-01, hostname/IP does not match: the certificate does not cover <host>, self-signed certificate, or a chain that does not verify to a trusted root. A short RSA key (under 2048 bits) is named beside it. In -f json the finding is an issues entry shaped like any other (ruleId, name, description, solution, category, group, severity, and a checks entry with status: "fail", the cause in message and legacyValue, and the start URL in affectedPages); the xml and llm formats carry a <finding rule="security/tls-certificate" status="fail"> element and the text format a security/tls-certificate: fail: ... line.

There is no finding when the failure is TLS but not a certificate problem the handshake can name: a plain-HTTP port answering a TLS request, a server whose only protocols or key type the runtime refuses, a start URL that redirected and failed on another host’s handshake that the start host’s handshake cannot explain. The report is then the plain unreachable one with the runtime’s reason. The finding follows rule selection: --rule-exclude security/tls-certificate, [rules] disable and [rule_options."security/tls-certificate"] enabled = false suppress it, and the run still ends unreachable. A start URL that is unreachable for another reason (a DNS failure, a refused connection, a timeout) is reported as before, with no certificate finding. The URL in affectedPages is the start URL; when it redirected, the certificate problem may be on the host it redirected to, which the cause names when it is a name problem.

Behind an HTTP proxy

When HTTPS_PROXY or HTTP_PROXY (or the lowercase names) is set, the handshake goes through the proxy, never around it: squirrel opens a CONNECT tunnel to host:port, then does TLS inside it with the hostname as SNI and verifies the certificate itself. The proxy only relays bytes, so the result is the same pass, warning or failure as without a proxy. The address check described above still applies first: squirrel resolves the name once, refuses a link-local, cloud metadata or (for any host but the audited one) private answer before sending anything, and the CONNECT names that vetted address, not the name, so the proxy’s own DNS or a rebinding answer cannot send the tunnel somewhere else. The hostname is still the SNI and verification name. No direct socket to the host is opened while a proxy applies. A name squirrel cannot resolve itself is not checked, even if the proxy could resolve it, and a proxy whose policy only allows hostnames will refuse the address CONNECT and give a not checked entry with its status (see the opt-in mode below). A host matched by NO_PROXY (*, a host, .suffix or *.suffix, with an optional port; the first of NO_PROXY and no_proxy that is not empty) is probed directly. CIDR ranges such as 10.0.0.0/8 are not supported: an address in one is not matched by it. A proxy that answers CONNECT with an error (403, 407, 502), never answers, cannot be reached or sends an unreadable reply makes the rule not checked with that reason, and so does a proxy this check cannot tunnel through (an https: or socks proxy URL). Proxy credentials in the URL are sent as Proxy-Authorization and never printed.

On a local or private-network host, such as localhost or 192.168.1.10, the rule is skipped and left out of the score, because a dev server does not hold the production certificate. See Transport and delivery rules do not apply.

When a page fetch fails on a TLS error, the CLI makes one handshake per host, waiting at most 3 seconds, and the failure message names the cause it found, for example certificate has expired on {date} or the server did not send its intermediate certificate, instead of listing every possibility.

When the proxy owns DNS

A proxy that resolves names itself and allows connections by name refuses the address CONNECT above. Set tls_proxy_resolves_names = true under [crawler] and the handshake to the audited host and to its www or apex counterpart is requested by name (CONNECT host:443) with no local lookup. The hostname is still the SNI name and the certificate is still verified against it, and a proxy that refuses, hangs or sends an unreadable reply still gives not checked with that reason. The setting is off by default because of what it gives up: where those two names resolve is then the proxy’s decision, not squirrel’s. The counterpart is the rule’s own (from the registrable domain only, so blog.example.com has none), and only the audited site’s own port is requested by name. The setting applies to the rule’s handshake, which knows the audited site; the probe the crawl uses to explain a TLS failure of the start URL does not, so it never requests by name and keeps resolving, vetting and pinning here (it fails closed). Any other host, such as one taken from page content, is still resolved, vetted and pinned here, and an IP literal, a cloud metadata name and a name the guard refuses without a lookup are refused whatever the setting.

How to fix it

Renew before the certificate expires. Let’s Encrypt clients such as certbot renew at 30 days remaining by default, so a 90-day certificate inside the 16-day warning window has missed its renewal window and one inside the 7-day error threshold has missed several renewal attempts. Check the renewal job’s last run before anything else.

Issue the certificate for every hostname the site answers on, including www:

certbot certonly --nginx -d example.com -d www.example.com

Serve the full chain, meaning the leaf certificate followed by its intermediates. Most servers take this as one file:

ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

Use the fullchain.pem file, not cert.pem, which holds the leaf alone. Test the result from outside your network with openssl s_client -connect example.com:443 -servername example.com -showcerts, and check that Verify return code reads 0 (ok).

Rule IDsecurity/tls-certificate
CategorySecurity
ScopePer-site
Severityerror
Weight6/10

Options

OptionTypeDefaultDescription
warn_daysintegerunsetWarn when the certificate expires within this many days. Unset: the last third of the certificate’s lifetime less a renewal margin (16 days for a 90-day certificate).
error_daysintegerunsetError when the certificate expires within this many days. Unset: 7 days, or a tenth of the certificate’s lifetime for one under 70 days.
key_typesarray of rsa, ecdsa, ed25519, dsa["rsa", "ecdsa", "ed25519"]Public key types the certificate may use. Any other type warns, so a DSA key warns by default. At least one type.
rsa_min_bitsinteger (512 to 16384)2048Smallest RSA modulus that does not warn.
ecdsa_min_bitsinteger (112 to 1024)256Smallest elliptic curve that does not warn, as the curve size (256 for P-256, 384 for P-384).
dsa_min_bitsinteger (512 to 16384)2048Smallest DSA modulus that does not warn. Only meaningful when dsa is in key_types.
reject_weak_signaturebooleantrueWarn when the leaf is signed with SHA-1, MD5, MD4 or MD2.
min_tls_versionTLSv1, TLSv1.1, TLSv1.2, TLSv1.3TLSv1.2Warn when the negotiated protocol is lower. Only TLSv1.3 against a server that tops out at TLS 1.2 can warn (see tls-certificate-protocol).
check_counterpartbooleantrueAlso handshake with the www or apex counterpart of the audited host. false makes no second handshake.

Set warn_days to override the lifetime-relative default with a fixed number of days, for example to warn earlier if your renewal job runs less often than monthly. error_days must not be more than warn_days when both are set; an explicit warn_days also caps a derived error threshold.

Configuration example

[rule_options."security/tls-certificate"]
warn_days = 60
error_days = 14
# Stricter keys: RSA at 3072 bits or ECDSA P-384, no DSA, TLS 1.3 only
rsa_min_bits = 3072
ecdsa_min_bits = 384
min_tls_version = "TLSv1.3"
# A site with no www name to check
check_counterpart = false

An invalid value (an unknown key type, a bit size out of range, a version that does not exist) is refused with the option named.

Enable / disable

Disable this rule

[rules]
disable = ["security/tls-certificate"]

Disable all Security rules

[rules]
disable = ["security/*"]

Enable only this rule

[rules]
enable = ["security/tls-certificate"]

enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.

  • security/https: whether the page is served over HTTPS at all. This rule only judges the certificate once HTTPS is in use.
  • security/hsts: the header that keeps browsers on HTTPS once a certificate is trusted.
  • security/http-to-https: whether the HTTP versions of your URLs redirect to HTTPS.

References

Check your site

Run squirrel audit https://example.com and open the Security section of the report. The tls-certificate-expiry check shows the issuer, the expiry date and the days remaining even when nothing is wrong. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.

Type to search…

↑↓ navigate↵ openesc close