pub enum TlsCert {
PemPaths {
cert_path: String,
key_path: String,
client_auth: Option<ClientAuth>,
},
Der {
certs: Arc<Vec<CertificateDer<'static>>>,
key: Arc<PrivateKeyDer<'static>>,
client_auth: Option<ClientAuth>,
},
Resolver {
resolver: Arc<dyn ResolvesServerCert>,
client_auth: Option<ClientAuth>,
},
}Expand description
Optional TLS material the builder can attach to a TLS-mode server.
Variants:
TlsCert::PemPaths— load cert and key from disk on every spawn.TlsCert::Der— pre-loaded DER cert chain + key.TlsCert::Resolver— user-suppliedrustls::server::ResolvesServerCertfor SNI multi-cert serving or hot-reloadable certificates (seeReloadableResolver).
Variants§
PemPaths
Filesystem paths for cert + key PEM files.
Fields
Der
tls only.Pre-loaded DER cert chain + key. Useful when certs come from secret storage rather than the filesystem.
Fields
certs: Arc<Vec<CertificateDer<'static>>>DER-encoded certificate chain (leaf first).
key: Arc<PrivateKeyDer<'static>>DER-encoded private key.
client_auth: Option<ClientAuth>Optional mTLS policy.
Resolver
tls only.User-supplied certificate resolver. The most flexible variant — drives
SNI multi-cert serving, hot reload (see ReloadableResolver), and any
custom logic that picks a cert per client-hello.
Fields
resolver: Arc<dyn ResolvesServerCert>The resolver used by rustls to pick a cert per handshake.
client_auth: Option<ClientAuth>Optional mTLS policy.
Implementations§
Source§impl TlsCert
impl TlsCert
Sourcepub fn pem_paths(cert: impl Into<String>, key: impl Into<String>) -> TlsCert
pub fn pem_paths(cert: impl Into<String>, key: impl Into<String>) -> TlsCert
Construct from filesystem paths (PEM cert + PEM key).
Sourcepub fn pem_paths_with_client_auth(
cert: impl Into<String>,
key: impl Into<String>,
client_auth: ClientAuth,
) -> TlsCert
Available on crate feature tls only.
pub fn pem_paths_with_client_auth( cert: impl Into<String>, key: impl Into<String>, client_auth: ClientAuth, ) -> TlsCert
tls only.Like TlsCert::pem_paths with an attached mTLS policy.
Sourcepub fn der(
certs: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> TlsCert
Available on crate feature tls only.
pub fn der( certs: Vec<CertificateDer<'static>>, key: PrivateKeyDer<'static>, ) -> TlsCert
tls only.Construct from pre-loaded DER cert chain + key.
Sourcepub fn resolver(resolver: Arc<dyn ResolvesServerCert>) -> TlsCert
Available on crate feature tls only.
pub fn resolver(resolver: Arc<dyn ResolvesServerCert>) -> TlsCert
tls only.Construct from a user-supplied certificate resolver. This is the entry
point for SNI multi-cert servers and hot-reload (see ReloadableResolver).
Sourcepub fn with_client_auth(self, auth: ClientAuth) -> TlsCert
Available on crate feature tls only.
pub fn with_client_auth(self, auth: ClientAuth) -> TlsCert
tls only.Returns a clone of the resolver (or no-op for static cert variants).
Useful when the caller wants to swap the live cert at runtime — they pass
in a ReloadableResolver via TlsCert::resolver and keep the Arc
for later .reload_*() calls.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TlsCert
impl !RefUnwindSafe for TlsCert
impl Send for TlsCert
impl Sync for TlsCert
impl Unpin for TlsCert
impl UnsafeUnpin for TlsCert
impl !UnwindSafe for TlsCert
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 more