Skip to main content

TlsObserver

Trait TlsObserver 

Source
pub trait TlsObserver:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn certificate_loaded(&self, _certificate: &Path) { ... }
    fn certificate_rejected(&self, _certificate: &Path, _reason: &str) { ... }
    fn certificate_watch_lost(&self, _reason: &str) { ... }
    fn accept_failed(&self, _reason: &str, _failures: u64) { ... }
    fn listener_failed(&self, _reason: &str) { ... }
    fn handshake_completed(&self) { ... }
    fn handshake_failed(&self) { ... }
}
Expand description

What a caller learns about certificates and handshakes.

A trait rather than a concrete reporter because the two applications count and log differently, and neither should have to adopt the other’s observability model to reuse the reload machinery. Every method has a default, so an application that wants none of it implements nothing.

Implementations are called from the accept loop and from the watcher task, so they must not block.

Provided Methods§

Source

fn certificate_loaded(&self, _certificate: &Path)

A certificate pair was read and adopted.

Source

fn certificate_rejected(&self, _certificate: &Path, _reason: &str)

A rotation was seen but not adopted; the previous pair still serves.

Source

fn certificate_watch_lost(&self, _reason: &str)

Rotations will no longer be noticed, while TLS keeps working.

Reported separately because it is otherwise invisible: nothing breaks until the certificate expires, which may be months away.

Source

fn accept_failed(&self, _reason: &str, _failures: u64)

The listener could not accept connections and is retrying.

failures counts attempts since the previous report, this one included: a persistent failure is summarised every REPORT_INTERVAL rather than reported once per attempt.

Source

fn listener_failed(&self, _reason: &str)

The listening socket is unusable and the listener has stopped accepting.

TlsListener::accept_tls also returns the error; this exists for the axum listener, which has no way to.

Source

fn handshake_completed(&self)

Source

fn handshake_failed(&self)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§