pub struct TlsManager { /* private fields */ }Expand description
TLS manager with SNI-based certificate selection and hot reload.
§Performance (PERF-P2-2)
Uses ahash::RandomState for 2-3x faster HashMap operations.
Implementations§
Source§impl TlsManager
impl TlsManager
Sourcepub fn new(min_version: TlsVersion) -> Self
pub fn new(min_version: TlsVersion) -> Self
Creates a new TLS manager with the specified minimum version.
Sourcepub fn with_tls12_minimum() -> Self
pub fn with_tls12_minimum() -> Self
Creates a TLS manager with TLS 1.2 minimum.
Sourcepub fn load_cert(&self, config: &TlsCertConfig) -> Result<(), TlsError>
pub fn load_cert(&self, config: &TlsCertConfig) -> Result<(), TlsError>
Loads a certificate from files.
§Security
- Validates file paths for traversal attacks
- Enforces file size limits
- Never logs private key paths or contents
Sourcepub fn set_default_cert(&self, config: &TlsCertConfig) -> Result<(), TlsError>
pub fn set_default_cert(&self, config: &TlsCertConfig) -> Result<(), TlsError>
Sets the default certificate for unmatched domains.
Sourcepub fn get_cert(&self, domain: &str) -> Option<Arc<CertifiedKey>>
pub fn get_cert(&self, domain: &str) -> Option<Arc<CertifiedKey>>
Gets the certificate for a domain using SNI matching.
§Matching Order
- Exact domain match
- Wildcard match (*.example.com matches sub.example.com)
- Default certificate
Sourcepub fn reload_all(&self) -> ReloadResult
pub fn reload_all(&self) -> ReloadResult
Reloads all certificates from their original paths. This is called on SIGHUP for hot reload.
§Hot Reload Strategy
Certificates are reloaded atomically: new certificates are loaded into temporary maps, then swapped in all at once. If any certificate fails to load, all successfully loaded certificates are still applied and failures are reported.
§Returns
ReloadResult containing counts of succeeded/failed reloads and error details.
Sourcepub fn configured_domains(&self) -> Vec<String>
pub fn configured_domains(&self) -> Vec<String>
Returns the list of configured domains (for monitoring/diagnostics).
Sourcepub fn has_cert_config(&self, domain: &str) -> bool
pub fn has_cert_config(&self, domain: &str) -> bool
Returns true if a certificate is configured for the given domain.
Sourcepub fn min_version(&self) -> TlsVersion
pub fn min_version(&self) -> TlsVersion
Returns the minimum TLS version.
Sourcepub fn cert_count(&self) -> usize
pub fn cert_count(&self) -> usize
Returns the number of loaded certificates.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TlsManager
impl !RefUnwindSafe for TlsManager
impl Send for TlsManager
impl Sync for TlsManager
impl Unpin for TlsManager
impl UnsafeUnpin for TlsManager
impl UnwindSafe for TlsManager
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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