pub struct TlsConfig { /* private fields */ }Expand description
Immutable shared TLS configuration for a client.
Construct via TlsConfig::builder() or TlsConfig::builder_with_defaults().
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn builder() -> TlsConfigBuilder
pub fn builder() -> TlsConfigBuilder
Create a builder with secure defaults (verification enabled, native roots preferred, SNI enabled).
Sourcepub fn builder_with_defaults() -> TlsConfigBuilder
pub fn builder_with_defaults() -> TlsConfigBuilder
Create a builder from the default configuration.
This is identical to TlsConfig::builder() and exists for
discoverability.
Sourcepub fn danger_accept_invalid_certs(self, accept: bool) -> Self
pub fn danger_accept_invalid_certs(self, accept: bool) -> Self
Enable or disable certificate and hostname verification while retaining the rest of this configuration.
Sourcepub fn tls_connector(&self) -> Result<TlsConnector>
pub fn tls_connector(&self) -> Result<TlsConnector>
Build a tokio_rustls::TlsConnector from this TLS configuration.
This is the convenience entry point for
crate::network_stream::UpgradedStream::start_tls and other
contexts where a generic TLS upgrade must reflect the full
configured policy (custom CA, verification, SNI, version bounds,
client identity).
§Errors
Returns an error if the underlying rustls configuration cannot be
built (see Self::build_rustls_config).
Sourcepub fn build_rustls_config(&self) -> Result<ClientConfig>
pub fn build_rustls_config(&self) -> Result<ClientConfig>
Build a rustls::ClientConfig from this TLS configuration.
§Errors
Returns an error if the trust store, client certificates, or protocol versions cannot be configured.
Sourcepub fn verify_hostname(&self) -> bool
pub fn verify_hostname(&self) -> bool
Returns true if hostname verification is enabled.
Sourcepub fn verify_certificate(&self) -> bool
pub fn verify_certificate(&self) -> bool
Returns true if certificate verification is enabled.
Sourcepub fn sni_enabled(&self) -> bool
pub fn sni_enabled(&self) -> bool
Returns true if SNI is enabled.