Skip to main content

Refusal

Enum Refusal 

Source
#[non_exhaustive]
pub enum Refusal { NotPinned, NotAccepted, NotTrusted, ChainWhenPinned, NameMismatch, AddressDenied { rule: Option<usize>, }, PeerDenied { rule: Option<usize>, }, AddressUnknown, CertificateType, }
Expand description

Why this side refused a peer: its certificate, or its addresses under a policy’s access control list.

A verifier returns it inside rustls::Error::InvalidCertificate(CertificateError::Other(OtherError(..))), so rustls sends the certificate_unknown alert; Refusal::from_rustls and PeerError::refusal take it back out. AddressDenied and an AddressUnknown found at the ClientHello stop the handshake before any certificate: rustls sends access_denied, and the accept helpers report the refusal the same way. Expired and not-yet-valid certificates are rustls’s own CertificateError::Expired and NotValidYet.

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.
§

NotPinned

The certificate matches no fixed pin.

§

NotAccepted

The certificate is not one the trust store accepted. A server with a store-backed pin set records it as waiting, within the store’s limits, once the peer proved its key.

§

NotTrusted

The certificate matches no pin, and the CA policy does not trust its chain or names, or the Roots do not trust its chain (an unknown issuer, a bad signature, a certificate not for server authentication).

§

ChainWhenPinned

A pinned peer presented a certificate chain, which the policy does not allow (Policy::allow_chain_when_pinned).

§

NameMismatch

The server’s chain is trusted by the Roots, but the certificate is not for the server name the client dialled.

§

AddressDenied

The policy’s access control list denies the connection’s addresses: the rule at index rule, or its default when None. Decided from the ClientHello, before any certificate.

Fields

§rule: Option<usize>

The index of the deciding rule in the list; None for the default.

§

PeerDenied

The policy’s access control list denies this client’s certificate from these addresses: the rule at index rule, or its default when None. Decided before the trust store is consulted, so nothing is recorded as waiting.

Fields

§rule: Option<usize>

The index of the deciding rule in the list; None for the default.

§

AddressUnknown

The policy has an access control list, and the connection’s source address, or the local address a rule with a destination or port needs, is unknown: the list is not decided, and the connection is refused.

§

CertificateType

The two sides authenticate with different certificate types: one with X.509 certificates, the other with raw public keys (RFC 7250). The side that finds out ends the handshake with this refusal and the other sees the handshake_failure alert. A server that serves both picks its configuration from the ClientHello (offers_raw_public_key).

Implementations§

Source§

impl Refusal

Source

pub fn from_rustls(error: &Error) -> Option<Self>

The refusal inside error, when one of this crate’s verifiers produced it, or the certificate type extensions of the two sides disagree.

Trait Implementations§

Source§

impl Clone for Refusal

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 Copy for Refusal

Source§

impl Debug for Refusal

Source§

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

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

impl Display for Refusal

Source§

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

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

impl Eq for Refusal

Source§

impl Error for Refusal

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl Hash for Refusal

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Refusal

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Refusal

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.