Skip to content

Optimize storage call for secondary unused issuer in loadCertResourceAnyIssuer - #407

Open
mbardelmeijer wants to merge 2 commits into
caddyserver:masterfrom
mbardelmeijer:load-first-usable-cert
Open

Optimize storage call for secondary unused issuer in loadCertResourceAnyIssuer#407
mbardelmeijer wants to merge 2 commits into
caddyserver:masterfrom
mbardelmeijer:load-first-usable-cert

Conversation

@mbardelmeijer

Copy link
Copy Markdown
Contributor

Open to suggestions on this!

The primary goal is to avoid touching the second issuer on certificate load if the first issuer's certificate is sufficient.

This was discovered with #402, where the local cache was serving the 3 files, but then a ground truth storage call was made (1 extra storage call), for the second issuer.

Made it opt-in now, but we can also rework it so it's always applied.

Summary

  • Adds Config.LoadFirstUsableCert. When set, loading a certificate stops reading further issuers once a preferred one has a usable certificate (one that does not need renewal), avoiding storage round-trips for unused failover issuers.
  • Still reads past missing or renewal-due certificates so failover certs are found and the newest still wins when none is usable.
  • Extracts shared renewalInfo helper used by the early-exit check and managedCertNeedsRenewal.

By default, loading a certificate reads every configured issuer and
serves the newest resource. That costs a storage round-trip per issuer
on every load, including for issuers that have never issued for that
name — the usual case for a failover CA.

When LoadFirstUsableCert is set, a load stops once a preferred issuer
has a certificate that does not need renewal. Issuers with no cert, or
with one due for renewal, are still read so failover certificates are
found and the newest still wins when none is usable.
Resolve loadCertResourceAnyIssuer conflict by keeping LocalCache's
storage parameter alongside LoadFirstUsableCert early-exit logic.
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