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§impl Debug for RustlsClientConfig
impl Debug for RustlsClientConfig
Source§impl Default for RustlsClientConfig
impl Default for RustlsClientConfig
Source§fn default() -> Self
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.