pub struct TlsParametersBuilder { /* private fields */ }
Expand description
Builder for TlsParameters
Implementations§
Source§impl TlsParametersBuilder
impl TlsParametersBuilder
Sourcepub fn certificate_store(self, cert_store: CertificateStore) -> Self
pub fn certificate_store(self, cert_store: CertificateStore) -> Self
Set the source for the base set of root certificates to trust.
Sourcepub fn add_root_certificate(self, cert: Certificate) -> Self
pub fn add_root_certificate(self, cert: Certificate) -> Self
Add a custom root certificate
Can be used to safely connect to a server using a self signed certificate, for example.
Sourcepub fn dangerous_accept_invalid_hostnames(
self,
accept_invalid_hostnames: bool,
) -> Self
pub fn dangerous_accept_invalid_hostnames( self, accept_invalid_hostnames: bool, ) -> Self
Controls whether certificates with an invalid hostname are accepted
Defaults to false
.
§Warning
You should think very carefully before using this method. If hostname verification is disabled any valid certificate, including those from other sites, are trusted.
This method introduces significant vulnerabilities to man-in-the-middle attacks.
Hostname verification can only be disabled with the native-tls
TLS backend.
Sourcepub fn set_min_tls_version(self, min_tls_version: TlsVersion) -> Self
pub fn set_min_tls_version(self, min_tls_version: TlsVersion) -> Self
Controls which minimum TLS version is allowed
Defaults to Tlsv12
.
Sourcepub fn dangerous_accept_invalid_certs(self, accept_invalid_certs: bool) -> Self
pub fn dangerous_accept_invalid_certs(self, accept_invalid_certs: bool) -> Self
Controls whether invalid certificates are accepted
Defaults to false
.
§Warning
You should think very carefully before using this method. If certificate verification is disabled, any certificate is trusted for use, including:
- Self signed certificates
- Certificates from different hostnames
- Expired certificates
This method should only be used as a last resort, as it introduces significant vulnerabilities to man-in-the-middle attacks.
Sourcepub fn build(self) -> Result<TlsParameters, Error>
pub fn build(self) -> Result<TlsParameters, Error>
Creates a new TlsParameters
using native-tls, boring-tls or rustls
depending on which one is available
Sourcepub fn build_native(self) -> Result<TlsParameters, Error>
pub fn build_native(self) -> Result<TlsParameters, Error>
Creates a new TlsParameters
using native-tls with the provided configuration
Trait Implementations§
Source§impl Clone for TlsParametersBuilder
impl Clone for TlsParametersBuilder
Source§fn clone(&self) -> TlsParametersBuilder
fn clone(&self) -> TlsParametersBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more