pub struct TlsConfigBuilder { /* private fields */ }Expand description
Builder of TlsConfig
Implementations§
Source§impl TlsConfigBuilder
impl TlsConfigBuilder
Sourcepub fn provider(self, v: TlsProvider) -> Self
pub fn provider(self, v: TlsProvider) -> Self
The provider to use.
Defaults to TlsProvider::Rustls.
Sourcepub fn client_cert(self, v: Option<ClientCert>) -> Self
pub fn client_cert(self, v: Option<ClientCert>) -> Self
Client certificate chain with corresponding private key.
Defaults to None.
Sourcepub fn root_certs(self, v: RootCerts) -> Self
pub fn root_certs(self, v: RootCerts) -> Self
The set of trusted root certificates to use to validate server certificates.
Defaults to WebPki.
Sourcepub fn use_sni(self, v: bool) -> Self
pub fn use_sni(self, v: bool) -> Self
Whether to send SNI (Server Name Indication) to the remote server.
This is used by the server to determine which domain/certificate we are connecting to for servers where multiple domains/sites are hosted on the same IP.
Defaults to true.
Sourcepub fn disable_verification(self, v: bool) -> Self
pub fn disable_verification(self, v: bool) -> Self
WARNING Disable all server certificate verification.
This breaks encryption and leaks secrets. Must never be enabled for code where any level of security is required.
Sourcepub fn unversioned_rustls_crypto_provider(self, v: Arc<CryptoProvider>) -> Self
pub fn unversioned_rustls_crypto_provider(self, v: Arc<CryptoProvider>) -> Self
Specific CryptoProvider to use for rustls.
§UNSTABLE API
NOTE: This API is not guaranteed for semver.
rustls is not (yet) semver 1.x and ureq can’t promise that this API is upheld.
If rustls makes a breaking change regarding CryptoProvider their configuration,
or incompatible data types between rustls versions, ureq will NOT bump a major version.
ureq will update to the latest rustls minor version using ureq minor versions.
§Feature flags
This requires either feature rustls or rustls-no-provider, you probably
want the latter when configuring an explicit crypto provider since
rustls compiles with ring, while rustls-no-provider does not.
§Example
This example uses aws-lc-rs for the Agent. The following
depdendencies would compile ureq without ring and only aws-lc-rs.
Cargo.toml
ureq = { version = "3", default-features = false, features = ["rustls-no-provider"] }
rustls = { version = "0.23", features = ["aws-lc-rs"] }- Agent
use std::sync::Arc;
use ureq::{Agent};
use ureq::tls::{TlsConfig, TlsProvider};
use rustls::crypto;
let crypto = Arc::new(crypto::aws_lc_rs::default_provider());
let agent = Agent::config_builder()
.tls_config(
TlsConfig::builder()
.provider(TlsProvider::Rustls)
// requires rustls or rustls-no-provider feature
.unversioned_rustls_crypto_provider(crypto)
.build()
)
.build()
.new_agent();