Skip to main content

RustlsClientConfig

Struct RustlsClientConfig 

Source
pub struct RustlsClientConfig(/* private fields */);
Available on crate feature client only.
Expand description

Rustls ClientConfig wrapper used by RustlsConfig.

RustlsClientConfig::default trusts the platform or webpki roots (depending on the platform-verifier feature). Use RustlsClientConfig::from_root_cert_pem to trust a specific private or self-signed certificate instead, or convert an existing ClientConfig via From.

Implementations§

Source§

impl RustlsClientConfig

Source

pub fn from_root_cert_pem(pem: &[u8]) -> Result<Self>

Build a client configuration that trusts exactly the certificate(s) in pem.

Unlike RustlsClientConfig::default, this consults neither the platform trust store nor the webpki root bundle — the provided roots are the only trust anchors. Server authentication is otherwise unchanged: certificate chains, signatures, expiry, and server name are all still verified against these roots. This is the right tool for talking to a service that presents a private or self-signed certificate.

The crate’s configured crypto provider and default ALPN protocol list (h2, http/1.1) are reused.

§Errors

Returns an error if pem contains no certificates or cannot be parsed, or if the resulting trust anchors are rejected by the verifier builder.

Source§

impl RustlsClientConfig

Source

pub fn dangerously_accept_any_cert() -> Self

Available on crate feature dangerous only.

Build a client configuration that accepts any server certificate without verification.

⚠️ This disables server authentication entirely: handshake signatures are still checked, but the certificate is never validated against any trust anchor, so the connection is vulnerable to man-in-the-middle attacks. It exists for development against throwaway self-signed certificates and for --insecure-style CLI flags. For talking to a service with a known private certificate, prefer RustlsClientConfig::from_root_cert_pem, which keeps authentication intact.

This constructor is only available with the dangerous crate feature enabled, and logs a warning when called.

Trait Implementations§

Source§

impl Clone for RustlsClientConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RustlsClientConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RustlsClientConfig

Source§

fn default() -> Self

Verifies servers with rustls-platform-verifier when the platform-verifier feature is enabled (the default), and against the WebPKI roots compiled into the binary otherwise.

The platform verifier uses the operating system’s verifier and trust store on macOS, iOS, Windows, and Android. On Linux and other Unix systems it verifies against the system CA bundle — or, when SSL_CERT_FILE or SSL_CERT_DIR is set, against only the certificates those name.

§Panics

With the platform verifier on Linux and other Unix systems, panics if no CA certificates can be loaded: no system bundle is installed, or SSL_CERT_FILE and SSL_CERT_DIR name no readable certificates.

Source§

impl From<Arc<ClientConfig>> for RustlsClientConfig

Source§

fn from(rustls_config: Arc<ClientConfig>) -> Self

Converts to this type from the input type.
Source§

impl From<ClientConfig> for RustlsClientConfig

Source§

fn from(rustls_config: ClientConfig) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.