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 moreSource§fn default() -> SharedTlsProfiles
fn default() -> SharedTlsProfiles
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.