Repository navigation
feat: acme.json cleanup management - #103
Merged
Merged
Conversation
DavidePrincipi
force-pushed
the
feat-7544
branch
6 times, most recently
from
September 5, 2025 08:30
80cf1ef to
8740610
Compare
DavidePrincipi
force-pushed
the
feat-7544
branch
3 times, most recently
from
September 11, 2025 15:43
8289489 to
e28b611
Compare
DavidePrincipi
marked this pull request as ready for review
September 15, 2025 15:36
DavidePrincipi
marked this pull request as draft
September 15, 2025 15:38
DavidePrincipi
force-pushed
the
feat-7544
branch
3 times, most recently
from
September 17, 2025 14:43
ab046b4 to
7d66c10
Compare
DavidePrincipi
marked this pull request as ready for review
September 17, 2025 15:02
DavidePrincipi
force-pushed
the
feat-7544
branch
from
September 17, 2025 16:01
7d66c10 to
4682dd7
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements richer certificate management operations for Traefik with better visibility, control, and safer operations when handling certificates and HTTP routes. The primary goal is to provide more granular control over ACME certificate lifecycle and improve error handling.
Key Changes
- Introduce
list-certificates-v2action with detailed certificate attributes and enhanced output format - Modify certificate deletion to use serial/path identifiers instead of FQDN for more precise targeting
- Add
set-default-certificateaction for dedicated default certificate management with validation
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/20_traefik_certificates_api.robot |
Updates test cases to use new serial/path-based certificate deletion API |
imageroot/pypkg/cert_helpers.py |
Major refactoring with new certificate management functions and improved ACME handling |
imageroot/actions/set-route/validate-input.json |
Adds optional cleanup and validation options for Let's Encrypt certificates |
imageroot/actions/set-route/20writeconfig |
Implements certificate cleanup functionality when disabling Let's Encrypt |
imageroot/actions/set-route/11validate_host |
Adds optional certificate validation during route configuration |
imageroot/actions/set-default-certificate/validate-input.json |
Schema for new default certificate action |
imageroot/actions/set-default-certificate/50set_default_certificate |
Implementation of default certificate management |
imageroot/actions/set-certificate/20writeconfig |
Refactors to use new certificate request functions |
imageroot/actions/set-certificate/05check_routes |
Simplifies route conflict checking using new helper functions |
imageroot/actions/list-certificates-v2/validate-output.json |
Schema for enhanced certificate listing output |
imageroot/actions/list-certificates-v2/50list_certificates_v2 |
Implementation of detailed certificate listing |
imageroot/actions/delete-route/validate-input.json |
Adds optional cleanup parameter |
imageroot/actions/delete-route/21sync_hosts |
Converts to placeholder implementation |
imageroot/actions/delete-route/20file |
Implements certificate cleanup when deleting routes |
imageroot/actions/delete-certificate/validate-output.json |
Removes unnecessary type constraint |
imageroot/actions/delete-certificate/validate-input.json |
Changes API to use serial/path instead of FQDN |
imageroot/actions/delete-certificate/20writeconfig |
Refactors to use new purging functions |
README.md |
Updates documentation for new actions and modified APIs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
DavidePrincipi
force-pushed
the
feat-7544
branch
from
September 19, 2025 12:43
d90f9d9 to
d2ae3b0
Compare
Amygos
approved these changes
Sep 23, 2025
- read acme.json (internal) and certificates from custom directory - mark the default certificate - mark certificates matching automatic HTTP routes with Let'Encrypt enabled - parse and format validity dates - calculate validity state: valid, expiring (30 days left), expired - extract also attributes: issuer, subject, serial, and path
Delete certificates matching the given serial number (for internal certs), or path (for custom certs). If acme.json is modified, Traefik is immediately restarted. The names of the removed certificate are notified with certificate-changed event. If they match an HTTP route's Host name, ACME cert resolver is forcibly disabled for that route, to prevent further ACME requests.
If the deleted certificate is the one set as Traefik's default ACME certificate, reset the configuration to prevent an immediate request for a new equivalent certificate.
Completely override the default certificate configuration with a new list of names. The first element of the list is used as main name. Before issuing an ACME request, ensure that no certificate in acme.json has the same set of names. The new set of names is written to default configuration for a time-boxed check. During this time frame, Traefik may expose its self-signed certificate.
Require synchronous validation of Let's Encrypt certificate with the new "lets_encrypt_check" request flag. A temporary Traefik route is created to trigger a new ACME certificate request. If the certificate is obtained validation passes, otherwise set-route fails with a validation error.
Introduce the "lets_encrypt_cleanup" flag to the set-route and delete-route actions to control Traefik restarts. The flag is disabled by default to ensure backward compatibility: - delete-route is triggered during uninstall, where a Traefik restart is unexpected and must be avoided. - set-route is triggered during configuration. A restart should only occur if the application explicitly enables the flag and informs the Admin. Note: during delete-route, write-hosts helper call was removed because the automatic Traefik restart implicitly calls it.
Either `path` or `serial` must be provided. `fqdn` is now ignored.
DavidePrincipi
force-pushed
the
feat-7544
branch
2 times, most recently
from
September 23, 2025 16:03
65b1f1c to
9959186
Compare
Move list-certificates-v2 implementation to stable list-certificates action to preserve current authorizations.
DavidePrincipi
force-pushed
the
feat-7544
branch
from
September 23, 2025 16:09
9959186 to
e5985f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is adding API actions for richer certificate operations, better visibility, more control, and safer operations when altering/removing certs and HTTP routes.
Changes summary:
list-certificates-v2action, that will replacelist-certificatesin a future PR.delete-certificateinput key. Restart Traefik if acme.json was changed.set-default-certificateaction, specifically for the Traefik default certificate. Return ACME error, if present.set-certificateas a special case ofset-default-certificate, retaining current behaviour for existing apps.set-routecertificate optional validation when lets_encrypt:true.1 Return ACME error, if present.set-routeoptional Traefik restart when lets_encrypt:false.1delete-routeoptional Traefik restart if a Let's Encrypt certificate was obtained.1See also individual commit messages.
Further work:
Refs NethServer/dev#7544
Footnotes
New apps can enable and leverage this behavior as wanted. Existing apps can continue to use the actions as they are. ↩ ↩2 ↩3