Skip to main content

tls_config_from_pem

Function tls_config_from_pem 

Source
pub fn tls_config_from_pem(
    extra_roots_pem: Option<&[u8]>,
    client_identity_pem: Option<(&[u8], &[u8])>,
) -> Result<ClientConfig, ClientError>
Available on crate feature tls-rustls only.
Expand description

Builds a ClientConfig from PEM: extra roots and a client identity.

It trusts what default_tls_config trusts plus every certificate in extra_roots_pem, and presents the client certificate chain and private key in client_identity_pem (mutual TLS).

A self-signed agent is reached by passing its certificate as a root, which trusts that one certificate and nothing else it could sign; there is no option that turns verification off.

ยงErrors

ClientError::Transport when a PEM block does not parse, a root is not a usable trust anchor, extra_roots_pem holds no certificate, or the key does not match the chain.