[go: up one dir, main page]

Struct TlsConfigBuilder

Source
pub struct TlsConfigBuilder { /* private fields */ }
Expand description

Builder of TlsConfig

Implementations§

Source§

impl TlsConfigBuilder

Source

pub fn provider(self, v: TlsProvider) -> Self

The provider to use.

Defaults to TlsProvider::Rustls.

Source

pub fn client_cert(self, v: Option<ClientCert>) -> Self

Client certificate chain with corresponding private key.

Defaults to None.

Source

pub fn root_certs(self, v: RootCerts) -> Self

The set of trusted root certificates to use to validate server certificates.

Defaults to WebPki.

Source

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.

Source

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.

Source

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();
Source

pub fn build(self) -> TlsConfig

Finalize the config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,