Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to single ACME default certificate #72

Merged
merged 11 commits into from
Feb 17, 2025
Merged

Conversation

DavidePrincipi
Copy link
Member

@DavidePrincipi DavidePrincipi commented Feb 7, 2025

This PR upgrades to Traefik v3 and changes the certificate configuration. While it aims to fix a bug of duplicated items from HTTP routers, it is the starting point for other bug fixes and new features.

  • Upgrade to Traefik v3. Customized routes are marked with "v2" syntax qualifier. During upgrade the previous configuration is copied into .v2 files/dirs.
  • Fix Common Name parsing error in certificate upload.
  • Upgrade ACME configuration: ad-hoc routes for ACME certs were removed. Use Traefik "defaultGeneratedCert" https://doc.traefik.io/traefik/https/tls/#acme-default-certificate, use a single certificate with a main name and SANs that overrides the self-signed certificate configuration.
  • Reimplement {set,get,delete}-certificate actions with the new configuration format.
  • Put acme.json file in a shared directory to ease access from APIs.

Refs

- Convert deprecated settings to v3
- (Re)generate config files for v3
- Mark config files for v3
- v2 -> v3 automated upgrade procedure
Remove entryPoints where a string value was used. Only a list value is
allowed. The legacy string value produces duplicates of router
configuration.
Only redirectscheme middleware is required by the http:// entrypoint.
Remove the tls.domains section from *-https routers, to avoid conflicts
with other certificate settings.

This change opens the way to certificates with SANs (wildcard included).

BREAKING CHANGE: Change the way routes are expressed in Traefik's router
configuration.
The rule syntax used by APIs is compatible with v3 and does not need the
"v2" mark to require the deprecated parsing method. This fix applies the
"v2" mark to custom routers definitions.
Use the same openssl command of the action validator to extract the
Common Name of the certificate.
Switch to defaultGeneratedCert by merging all certificate names into a
single certificate request. Names from HTTP routes are not considered.
If user's home is not the default /home, or if the volume has a custom
path the acme.json file is not found. Move acme.json storage out of
volume and make it accessible to actions from the module state/
directory.
Python library files do not need the executable bit.
@DavidePrincipi DavidePrincipi requested a review from Amygos February 7, 2025 10:50
@DavidePrincipi DavidePrincipi self-assigned this Feb 7, 2025
@DavidePrincipi DavidePrincipi force-pushed the feat-7158-1 branch 3 times, most recently from 3b2ea1c to d90942b Compare February 10, 2025 15:55
Comment on lines +16 to +27
if fqdn in cert_helpers.read_custom_cert_names():
response = {
"fqdn": fqdn,
"type": "custom",
"obtained": True,
}
elif fqdn in cert_helpers.read_default_cert_names():
response = {
"fqdn": fqdn,
"type": "internal",
"obtained": cert_helpers.has_acmejson_name(fqdn),
}
Copy link
Member

Choose a reason for hiding this comment

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

What happens if a custom certificate with the same name as one requested via set-certificate is uploaded?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should override the one from LE. At least from my tests it seems Traefik gives it priority over the default generated cert.

- Reimplement {set,get,delete}-certificate actions to request a single
  certificate with SANs. Use Traefik's defaultGeneratedCert.

- Change list-certificates to list the ACME certificate host names and the
  custom/uploaded certs.

BREAKING CHANGE: the Traefik configuration does not create certificate
routers any more. Action data format is unchanged.
@DavidePrincipi DavidePrincipi merged commit dfb9d28 into main Feb 17, 2025
5 checks passed
@DavidePrincipi DavidePrincipi deleted the feat-7158-1 branch February 17, 2025 16:48
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.

2 participants