Skip to main content

Trust

Enum Trust 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§pins: Pins

The pinned certificates.

§ca: CaPolicy

The CA policy.

§

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.

Fields

§pins: Pins

The pinned certificates.

§roots: Roots

The roots.

Implementations§

Source§

impl Trust

Source

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.

Trait Implementations§

Source§

impl Clone for Trust

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 Trust

Source§

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

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

impl From<Trust> for ServerAuth

Source§

fn from(trust: Trust) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Trust

§

impl !UnwindSafe for Trust

§

impl Freeze for Trust

§

impl Send for Trust

§

impl Sync for Trust

§

impl Unpin for Trust

§

impl UnsafeUnpin for Trust

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Same for T

Source§

type Output = T

Should always be Self
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.