pub struct TlsConfig {
pub cert_path: Option<PathBuf>,
pub key_path: Option<PathBuf>,
pub ca_path: Option<PathBuf>,
pub mtls_enabled: bool,
pub alpn_protocols: Vec<Vec<u8>>,
pub skip_verification: bool,
pub server_name: Option<String>,
}quic only.Expand description
TLS/certificate configuration.
Fields§
§cert_path: Option<PathBuf>Path to the server certificate file (PEM format).
key_path: Option<PathBuf>Path to the server private key file (PEM format).
ca_path: Option<PathBuf>Path to the CA certificate for peer verification.
mtls_enabled: boolEnable mutual TLS (client certificate verification).
alpn_protocols: Vec<Vec<u8>>ALPN protocols to advertise.
Defaults to ["plumtree/1"].
skip_verification: boolINSECURE: Skip server certificate verification.
Only use for development/testing. Vulnerable to MITM attacks.
server_name: Option<String>Server name for TLS SNI (Server Name Indication).
This is used during TLS handshake for:
- SNI extension (allows server to select correct certificate)
- Certificate hostname verification (unless
skip_verificationis true)
For self-signed certificates, this should match the CN or SAN in the cert.
Common values: "localhost" for development, hostname/domain for production.
Default: "localhost" (suitable for self-signed certs).
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn with_cert_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_cert_path(self, path: impl Into<PathBuf>) -> Self
Builder method to set certificate path.
Sourcepub fn with_key_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_key_path(self, path: impl Into<PathBuf>) -> Self
Builder method to set key path.
Sourcepub fn with_ca_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_ca_path(self, path: impl Into<PathBuf>) -> Self
Builder method to set CA path.
Sourcepub fn with_alpn_protocols(self, protocols: Vec<Vec<u8>>) -> Self
pub fn with_alpn_protocols(self, protocols: Vec<Vec<u8>>) -> Self
Builder method to set ALPN protocols.
Sourcepub fn with_skip_verification(self, skip: bool) -> Self
pub fn with_skip_verification(self, skip: bool) -> Self
Builder method to skip verification (INSECURE).
Sourcepub fn with_server_name(self, name: impl Into<String>) -> Self
pub fn with_server_name(self, name: impl Into<String>) -> Self
Builder method to set server name for SNI.
Sourcepub fn has_custom_certs(&self) -> bool
pub fn has_custom_certs(&self) -> bool
Check if custom certificates are configured.
Sourcepub fn server_name_or_default(&self) -> &str
pub fn server_name_or_default(&self) -> &str
Get server name for TLS, defaulting to “localhost”.
Sourcepub fn alpn_protocols_or_default(&self) -> Vec<Vec<u8>>
pub fn alpn_protocols_or_default(&self) -> Vec<Vec<u8>>
Get the ALPN protocols, using defaults if not specified.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TlsConfig
impl RefUnwindSafe for TlsConfig
impl Send for TlsConfig
impl Sync for TlsConfig
impl Unpin for TlsConfig
impl UnwindSafe for TlsConfig
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> 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