canonical / observability-libs

A collection of charm libraries curated by the Observability team.
https://charmhub.io/observability-libs
Apache License 2.0
3 stars 8 forks source link

Add cert_handler library #49

Closed lucabello closed 1 year ago

lucabello commented 1 year ago

Issue

This PR addresses the issue of implementing TLS between the components of the cos-lite bundle.

Solution

The cert_manager.py library is a convenient wrapper around the tls_certificates library. It allows integrating TLS in charms quite smoothly.

Testing Instructions

Use this library to obtain a certificate in a charm and try to use it.

lucabello commented 1 year ago

Currently the main point of contention is if the cert_manager.py library should have a lib dependency on tls_certificates or not.

It has been mentioned that since the dependency is only on our charms side, an import guard could suffice as the final implementation would be cleaner. This is the approach that's currently implemented in this PR.

Illustrating both scenarios in terms of charm integration:

lucabello commented 1 year ago

Another useful feature to include in this library, I think, is to include saving the certificate to file once it's obtained, instead of only having it in peer relation (possibly by passing a folder path to the CertManager object itself, or having a good default).

This way a charm only needs to worry about using the certificate.

What do you think about it?