Skip to content

pki: add per-CA configurable maintenance_interval and renewal_window_ratio#7479

Merged
francislavoie merged 2 commits intocaddyserver:masterfrom
Amirhf1:pki/configurable-maintenance-and-renewal-window
Feb 15, 2026
Merged

pki: add per-CA configurable maintenance_interval and renewal_window_ratio#7479
francislavoie merged 2 commits intocaddyserver:masterfrom
Amirhf1:pki/configurable-maintenance-and-renewal-window

Conversation

@Amirhf1
Copy link
Contributor

@Amirhf1 Amirhf1 commented Feb 14, 2026

Summary

Adds per-CA configuration for certificate maintenance interval and renewal window ratio, as agreed in #7475.

Changes

  • CA struct (modules/caddypki/ca.go): New fields maintenance_interval (duration) and renewal_window_ratio (float in (0, 1]). Defaults: 10m and 0.2. Invalid ratio is clamped to default in Provision.
  • Maintenance (modules/caddypki/maintain.go): One goroutine per CA (maintenanceForCA) with that CA’s interval. needsRenewal is a method on *CA and uses the CA’s ratio (with fallback for zero/invalid).
  • PKI Start (modules/caddypki/pki.go): Starts maintenanceForCA(ca) for each CA instead of a single global maintenance().
  • Caddyfile (caddyconfig/httpcaddyfile/pkiapp.go): New options inside pki { ca { ... } }:
    • maintenance_interval <duration> (e.g. 5m, 1h)
    • renewal_window_ratio <ratio> (e.g. 0.15); must be in (0, 1]

Fixes #7475

…ratio

- Add MaintenanceInterval and RenewalWindowRatio to CA struct (JSON + Caddyfile).
- Run one maintenance goroutine per CA using its own interval.
- needsRenewal uses per-CA RenewalWindowRatio; invalid/zero ratio falls back to defaults.
- Caddyfile: maintenance_interval duration, renewal_window_ratio <0-1>.
- Tests: TestCA_needsRenewal, TestParsePKIApp for new options.

Fixes caddyserver#7475
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks!

@francislavoie francislavoie added this to the v2.11.0 milestone Feb 15, 2026
@francislavoie
Copy link
Member

Ah, there's a minor code style lint issue

@francislavoie francislavoie added the feature ⚙️ New feature or request label Feb 15, 2026
@francislavoie francislavoie changed the title pki: add per-CA configurable maintenance_interval and renewal_window_ratio pki: add per-CA configurable maintenance_interval and renewal_window_ratio Feb 15, 2026
@francislavoie francislavoie merged commit affbb99 into caddyserver:master Feb 15, 2026
25 checks passed
This was referenced Feb 20, 2026
@francislavoie francislavoie mentioned this pull request Feb 20, 2026
4 tasks
francislavoie added a commit to caddyserver/website that referenced this pull request Feb 22, 2026
francislavoie added a commit to caddyserver/website that referenced this pull request Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature ⚙️ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pki: make maintenance interval and renewal window ratio configurable?

2 participants