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

Add refresh_events to CertHandler #108

Merged
merged 8 commits into from
Sep 4, 2024
Merged

Add refresh_events to CertHandler #108

merged 8 commits into from
Sep 4, 2024

Conversation

michaeldmitry
Copy link
Contributor

@michaeldmitry michaeldmitry commented Sep 2, 2024

This PR adds a refresh_events option to CertHandler which will be observed to check if there are any changes to the CSR (e.g: newly added SANs). And if there are changes from the existing CSR, it will be replaced by a new one generated with the newest request details and subsequently provide a new certificate.

Context

In HA clusters, the coordinator currently requests a certificate with its own hostname given as a SAN. However, this certificate is passed on to the workers to be used by them. This leads to issues when services (e.g pebble check on the worker) tries to communicate with the worker server directly, they will get a certificate error saying that the certificate is valid for the coordinator not the worker.
This solution gives the option to the coordinator to specify the workers' hostnames as SANS whenever a worker is added or removed by, for example, giving refresh_events=[self.cluster.on.changed] to check if the certificate needs to be refreshed.

Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

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

overall looks good, missing a little bit of comments/docstrings and ideally a test that demonstrates how a new csr is requested when you receive a refresh event and, say, your privkey has changed, and a new csr is NOT requested when all of the input params are unchanged.

lib/charms/observability_libs/v1/cert_handler.py Outdated Show resolved Hide resolved
lib/charms/observability_libs/v1/cert_handler.py Outdated Show resolved Hide resolved
lib/charms/observability_libs/v1/cert_handler.py Outdated Show resolved Hide resolved
@PietroPasotti PietroPasotti merged commit 5028ced into main Sep 4, 2024
13 checks passed
@PietroPasotti PietroPasotti deleted the add-refresh-event branch September 4, 2024 10:00
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.

4 participants