Skip to content

Keep serving valid certificates when ACME renewal fails - #234

Merged
enteriaza merged 1 commit into
masterfrom
188-bug-keep-serving-valid-cert-when-renewal-fails
Oct 21, 2026
Merged

enteriaza merged 1 commit into
masterfrom
188-bug-keep-serving-valid-cert-when-renewal-fails

Conversation

@enteriaza

Copy link
Copy Markdown
Collaborator

Summary

Fixes #188.

Prevent temporary ACME renewal failures from unnecessarily interrupting service availability or causing the systemd watchdog to restart a service while its existing TLS certificate remains valid.

Changes

  • Preserve a usable certificate: If an existing certificate is usable but due for renewal, a recoverable issuance failure no longer prevents startup or renewal handling from continuing with that certificate.
  • Classify failures correctly: Recoverable CA and transport failures are handled as renewal failures. Caller cancellation, storage/configuration failures, and unexpected programming errors continue to propagate rather than being silently treated as ordinary renewal failures.
  • Enforce certificate expiry in watchdog health: Watchdog health checks compare the current UTC time against the certificate's recorded NotAfter on every read. An expired certificate is unhealthy even if the last observed certificate status still reports it as usable.
  • Avoid unnecessary watchdog restarts: Being due for renewal alone does not make the service unhealthy while the current certificate remains valid.
  • Make health-state transitions safe: Certificate availability and expiry updates use atomic or volatile state operations. An unavailable state is published before expiry data is cleared, and replacement expiry data is published before availability is restored.
  • Verify host composition: Tests cover watchdog registration and shared TimeProvider dependency resolution.

Validation

  • Focused ACME and host-composition tests: 16 passed
  • VectorNNTPD.BackFillerService.Tests (Release x64): 1,324 passed
  • Release x64 solution build: passed
  • dotnet format VectorNNTP.slnx --verify-no-changes: passed
  • tools/Invoke-CodeQlAnalysis.ps1: completed successfully; six unrelated, pre-existing NntpSessionPool findings remain.

Behavioural guarantees

  • A valid existing certificate remains usable through recoverable renewal failures.
  • Renewal being due does not, by itself, block watchdog keep-alives.
  • Watchdog health becomes unhealthy at the certificate's exact NotAfter boundary.
  • A stale certificate-status observation cannot keep an expired certificate healthy.
  • Cancellation, storage/configuration errors, and unexpected failures are not silently swallowed.

@enteriaza enteriaza self-assigned this Oct 21, 2026
@enteriaza enteriaza added the bug Something isn't working label Oct 21, 2026
@enteriaza
enteriaza merged commit fcecdbc into master Oct 21, 2026
7 checks passed
@enteriaza
enteriaza deleted the 188-bug-keep-serving-valid-cert-when-renewal-fails branch October 21, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valid certificate in the renewal window fails startup and stops watchdog keep-alives

1 participant