pub struct RustlsClientConfig(/* private fields */);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
impl RustlsClientConfig
Sourcepub fn from_root_cert_pem(pem: &[u8]) -> Result<Self>
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
impl RustlsClientConfig
Sourcepub fn dangerously_accept_any_cert() -> Self
Available on crate feature dangerous only.
pub fn dangerously_accept_any_cert() -> Self
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
impl Clone for RustlsClientConfig
Source§fn clone(&self) -> RustlsClientConfig
fn clone(&self) -> RustlsClientConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more