pub struct SharedTlsProfiles { /* private fields */ }Expand description
Reloadable wrapper around TlsProfileMap.
Holds an Arc<parking_lot::RwLock<TlsProfileMap>> so the
inbound listener (via Self::build_sni_acceptor) and every
outbound peer supervisor can pick up cert / key / CA changes
without rebinding sockets or rebuilding their
tokio_rustls::TlsAcceptor. The resolver returned by
Self::build_sni_acceptor reads the inner map on every
handshake.
Clone is Arc-cheap.
§Examples
use std::collections::BTreeMap;
use dynomite::net::tls::{SharedTlsProfiles, TlsProfileMap};
let map = TlsProfileMap::build(None, BTreeMap::new()).unwrap();
let shared = SharedTlsProfiles::from_map(map);
assert!(shared.is_empty());Implementations§
Sourcepub fn from_map(map: TlsProfileMap) -> Self
pub fn from_map(map: TlsProfileMap) -> Self
Wrap an existing TlsProfileMap in a shared cell.
Sourcepub fn replace(&self, map: TlsProfileMap)
pub fn replace(&self, map: TlsProfileMap)
Atomically replace the inner profile map.
Subsequent handshakes (and outbound dials that consult
Self::client_config_for_dc) observe the new material;
already-negotiated TLS sessions are not affected.
Sourcepub fn client_config_for_dc(&self, dc: &str) -> Option<Arc<ClientConfig>>
pub fn client_config_for_dc(&self, dc: &str) -> Option<Arc<ClientConfig>>
Per-DC client config, with the legacy default as fallback. Reads the inner map at call time.
Sourcepub fn requires_client_auth(&self) -> bool
pub fn requires_client_auth(&self) -> bool
True when at least one wrapped profile pins a CA bundle.
Sourcepub fn build_sni_acceptor(&self) -> Result<Option<TlsAcceptor>, TlsError>
pub fn build_sni_acceptor(&self) -> Result<Option<TlsAcceptor>, TlsError>
Build a SIGHUP-aware tokio_rustls::TlsAcceptor.
The acceptor’s underlying ServerConfig holds a
resolver that re-reads the wrapped
Arc<parking_lot::RwLock<TlsProfileMap>> on every
handshake, so Self::replace takes effect on the next
inbound connection without rebinding the listener.
Returns None when the inner map is empty (caller stays
plaintext).
§Errors
Returns TlsError::Rustls when rustls rejects the
assembled root store or the verifier (e.g. a CA cert
the loader missed).
Trait Implementations§
Source§fn clone(&self) -> SharedTlsProfiles
fn clone(&self) -> SharedTlsProfiles
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more