Skip to content

LocalCache: reload cached certificates due for renewal from storage - #408

Open
mbardelmeijer wants to merge 1 commit into
caddyserver:masterfrom
mbardelmeijer:local-cache-stale-renewal
Open

LocalCache: reload cached certificates due for renewal from storage#408
mbardelmeijer wants to merge 1 commit into
caddyserver:masterfrom
mbardelmeijer:local-cache-stale-renewal

Conversation

@mbardelmeijer

Copy link
Copy Markdown
Contributor

Follow-up to #402.

The local cache only changes when this instance reads or writes it, so it never learns of a renewal done by another instance. With a single issuer that heals itself: the stale certificate enters its renewal window and the renewal path reads storage. With several issuers it can go unnoticed indefinitely: an expired certificate from the preferred issuer in the local cache loses to a still-valid fallback certificate, which is served and never triggers a storage read, while storage holds a renewed preferred certificate the instance never sees.

A cached certificate due for renewal is exactly the one a peer is likely to have replaced, so loadCertResource now reads that issuer from storage instead. The read refreshes the local copy, so it is paid once per renewal; certificates that are not due are still served locally without touching storage. If storage cannot be read, the cached copy is served as before.

TestLocalCacheStaleCertRenewedByPeer reproduces the two-issuer scenario and fails without the fix.

The local cache only changes when this instance reads or writes it, so it
never learns of a renewal done by another instance. That is fine while the
stale certificate is the one being served: it enters its renewal window,
and the renewal path reads storage and picks up the peer's renewal.

With several issuers it can go unnoticed indefinitely. An expired
certificate from the preferred issuer in the local cache loses to a
fallback issuer's certificate that is still valid, which is served and
never triggers a storage read, while storage holds a renewed preferred
certificate the instance never sees.

A cached certificate due for renewal is exactly the one a peer is likely
to have replaced, so read that issuer from storage instead. The read
refreshes the local copy, so it is paid once per renewal; certificates
that are not due are still served locally without touching storage.
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