Skip to content

feat(alertd): caddy certificate expiry check#495

Merged
passcod merged 2 commits into
mainfrom
alertd-caddy-certs
Jun 16, 2026
Merged

feat(alertd): caddy certificate expiry check#495
passcod merged 2 commits into
mainfrom
alertd-caddy-certs

Conversation

@passcod

@passcod passcod commented Jun 16, 2026

Copy link
Copy Markdown
Member

🤖 New alertd healthcheck caddy_certs.

Caddy auto-renews managed certs at roughly a third of their lifetime before expiry, so a cert nearing expiry means renewal is failing — invisible today until the site goes down. Reads caddy's on-disk cert store and flags two signals:

  • Expiry (on-disk leaf), with thresholds scaled to each cert's own lifetime, anchored on the 90-day case (warn 21d left, fail 7d). A 45-day cert warns ~10d out, a 6-day cert ~1.4d out.
  • Served vs on-disk mismatch: a TLS handshake dialed straight at 127.0.0.1:443 (the SNI selects the vhost but the connection never leaves the box) reads the served leaf and compares it to disk. A mismatch means caddy is serving a stale cert and needs a reload to pick up a renewal — a warning.

Wildcard-only certs skip the served comparison (no concrete SNI to dial). Handshake is timeout-bounded; a failed handshake is recorded, not alarmed. Skips entirely when caddy's cert store isn't found.

Promotes already-transitive rustls / tokio-rustls / x509-parser to direct deps — no new crates enter the tree (Cargo.lock change is just the three dependency edges). Threshold scaling is a pure classify fn with tests for the 90/45/6-day profiles.

@passcod passcod force-pushed the alertd-caddy-certs branch 3 times, most recently from 96d6537 to a9ebe1e Compare June 16, 2026 10:35
Caddy auto-renews managed certs well before expiry, so a cert nearing expiry
means renewal is failing — invisible until the site goes down. Reads caddy on-
disk cert store and flags two signals: expiry, with thresholds scaled to each
cert lifetime (anchored on warn 21d / fail 7d for 90-day certs, so 45-day and
6-day profiles get proportionally shorter windows); and a served-vs-on-disk
mismatch, detected by a TLS handshake dialed straight at 127.0.0.1 (the SNI
selects the vhost but the connection never leaves the box) comparing the served
leaf against disk — a mismatch means caddy needs a reload to pick up a renewal.

Skips when caddy cert store is not found. Promotes already-transitive rustls /
tokio-rustls / x509-parser to direct deps; no new crates pulled.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@passcod passcod force-pushed the alertd-caddy-certs branch from a9ebe1e to c9b3e57 Compare June 16, 2026 13:25
@passcod passcod enabled auto-merge June 16, 2026 13:29
@passcod passcod added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 0fb0c9e Jun 16, 2026
9 checks passed
@passcod passcod deleted the alertd-caddy-certs branch June 16, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant