Observability Libs

  • By Jon Seager
Channel Revision Published Runs on
latest/edge 34 Yesterday
Ubuntu 20.04
juju deploy observability-libs --channel edge
Show information

Platform:

charms.observability_libs.v1.cert_handler

Overview.

This document explains how to use the CertHandler class to create and manage TLS certificates through the tls_certificates interface.

The goal of the CertHandler is to provide a wrapper to the tls_certificates library functions to make the charm integration smoother.

Library Usage

This library should be used to create a CertHandler object, as per the following example:

self.cert_handler = CertHandler(
    charm=self,
    key="my-app-cert-manager",
    cert_subject="unit_name",  # Optional
)

You can then observe the library's custom event and make use of the key and cert:

self.framework.observe(self.cert_handler.on.cert_changed, self._on_server_cert_changed)

container.push(keypath, self.cert_handler.private_key)
container.push(certpath, self.cert_handler.servert_cert)

Since this library uses Juju Secrets it requires Juju >= 3.0.3.


def is_ip_address(value: str)

Description

Return True if the input value is a valid IPv4 address; False otherwise. None

class CertChanged

Description

Event raised when a cert is changed (becomes available or revoked). None

class CertHandlerEvents

Description

Events for CertHandler. None

class CertHandler

Description

A wrapper for the requirer side of the TLS Certificates charm library. None

Methods

CertHandler. __init__( self , charm: CharmBase )

CertHandler is used to wrap TLS Certificates management operations for charms.

Arguments

charm

The owning charm.

key

A manually-crafted, static, unique identifier used by ops to identify events. It shouldn't change between one event to another.

certificates_relation_name

Must match metadata.yaml.

cert_subject

Custom subject. Name collisions are under the caller's responsibility.

sans

DNS names. If none are given, use FQDN.

Description

CerHandler manages one single cert.

CertHandler. enabled( self )

Description

Boolean indicating whether the charm has a tls_certificates relation. None

CertHandler. private_key( self )

Description

Private key. None

CertHandler. private_key_secret_id( self )

Description

ID of the Juju Secret for the Private key. None

CertHandler. ca_cert( self )

Description

CA Certificate. None

CertHandler. ca_server_cert_secret_id( self )

Description

CA server cert secret id. None

CertHandler. server_cert( self )

Description

Server Certificate. None

CertHandler. chain( self )

Description

Return the ca chain. None