#[non_exhaustive]pub enum Trust {
Pinned(Pins),
Ca(CaPolicy),
PinnedOrCa {
pins: Pins,
ca: CaPolicy,
},
AnyWithKeyProof,
Roots(Roots),
PinnedOrRoots {
pins: Pins,
roots: Roots,
},
}Expand description
Whom to trust.
Every policy requires the peer to prove it holds the certificate’s key in the handshake.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pinned(Pins)
Only pinned certificates.
Ca(CaPolicy)
Certificates signed by a CA and matching name globs. Server role only.
PinnedOrCa
A pinned certificate, or one the CA policy trusts. Server role only.
AnyWithKeyProof
Any certificate whose key the peer proves; the caller decides from the returned
PeerIdentity afterwards.
Roots(Roots)
A server certificate that chains to these roots and is valid for the name dialled: the web PKI, as a browser trusts a server. Client role only.
PinnedOrRoots
A pinned server certificate, or one the roots trust for the name dialled. A pinned
certificate is taken as Pinned takes it, whatever its name. Client
role only.
Implementations§
Source§impl Trust
impl Trust
Sourcepub fn verify_client_chain(
&self,
policy: &Policy,
leaf: &[u8],
intermediates: &[&[u8]],
) -> Result<(), PeerError>
pub fn verify_client_chain( &self, policy: &Policy, leaf: &[u8], intermediates: &[&[u8]], ) -> Result<(), PeerError>
Checks a client certificate chain as this trust’s client verifier does when the chain
is presented: pins (Pinned), chain to the CA roots with the subject and SAN globs
(Ca), the pin first then the CA (PinnedOrCa), and the policy’s checks of a pinned
certificate (no chain unless allowed, validity dates). No key proof: use it only
for a certificate a TLS handshake already proved, such as one a proxy or host hands
over. A store-backed pin set records nothing as waiting.
§Errors
PeerError::Unsupported for the other trusts; PeerError::Policy,
PeerError::CaFile or PeerError::TrustPattern when the trust cannot be built
under policy; PeerError::Io of kind InvalidData wrapping the rustls error when
the chain is refused, from which PeerError::refusal takes the Refusal
(NotPinned, NotAccepted, NotTrusted, ChainWhenPinned); an expired or not yet
valid pinned certificate is rustls’s Expired / NotValidYet there.