pub struct CertResolver { /* private fields */ }Expand description
A certificate resolver that supports hot-swapping certificates.
Implements ResolvesServerCert so it can be used with rustls::ServerConfig.
The inner RwLock allows updating the certificate without restarting the
TLS acceptor.
Uses std::sync::RwLock (not tokio::sync::RwLock) because
ResolvesServerCert::resolve is synchronous. A tokio RwLock required
try_read() which returns None during certificate updates, causing TLS
handshake failures. A std RwLock blocks briefly during the (very fast)
pointer swap, so resolve never returns None.
Implementations§
Source§impl CertResolver
impl CertResolver
Sourcepub fn new(key: CertifiedKey) -> Self
pub fn new(key: CertifiedKey) -> Self
Create a new resolver with the given certified key.
Sourcepub fn update(&self, key: CertifiedKey)
pub fn update(&self, key: CertifiedKey)
Update the certificate. Subsequent TLS handshakes will use the new certificate.
This acquires a std RwLock write guard, which blocks briefly but is
safe because the critical section is a single pointer swap.
If the lock is poisoned (prior panic during a write), we recover by
clearing the poison — the old Arc<CertifiedKey> is still valid and
we are replacing it with a fresh one anyway.
Trait Implementations§
Source§impl Debug for CertResolver
impl Debug for CertResolver
Source§impl ResolvesServerCert for CertResolver
impl ResolvesServerCert for CertResolver
Source§fn resolve(&self, _client_hello: ClientHello<'_>) -> Option<Arc<CertifiedKey>>
fn resolve(&self, _client_hello: ClientHello<'_>) -> Option<Arc<CertifiedKey>>
Source§fn only_raw_public_keys(&self) -> bool
fn only_raw_public_keys(&self) -> bool
Auto Trait Implementations§
impl !Freeze for CertResolver
impl RefUnwindSafe for CertResolver
impl Send for CertResolver
impl Sync for CertResolver
impl Unpin for CertResolver
impl UnsafeUnpin for CertResolver
impl UnwindSafe for CertResolver
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
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 more