Skip to main content

tls2/
errors.rs

1use core::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum Error {
5    InvalidConfiguration,
6
7    // ── Record layer ──
8    InsufficientBuffer,
9    RecordOverflow,
10    UnexpectedAlert {
11        level: u8,
12        description: u8,
13    },
14    ConnectionClosed,
15
16    // ── Decode / Encode ──
17    DecodeError,
18    EncodeError,
19    UnsupportedCipherSuite,
20    UnsupportedKeyExchangeGroup,
21
22    // ── Handshake ──
23    HandshakeDone,
24    UnexpectedMessage,
25    HandshakeFailure,
26    HandshakeAborted {
27        level: u8,
28        description: u8,
29    },
30    InvalidSignature,
31    TranscriptMismatch,
32
33    // ── Certificate verification ──
34    /// Chain is empty
35    CertificateEmptyChain,
36    /// Server name is required for X.509 but was not provided
37    CertificateServerNameRequired,
38    /// No SAN DNS name matched the requested server name
39    CertificateSubjectNameMismatch,
40    /// End-entity certificate has cA=true
41    CertificateEndEntityMustNotBeCa,
42    /// EKU does not include serverAuth
43    CertificateEkuDoesNotIncludeServerAuth,
44    /// An intermediate CA does not have cA=true
45    CertificateIntermediateNotCa,
46    /// Issuer DN of a cert does not match subject DN of the issuer
47    CertificateIssuerSubjectDnMismatch,
48    /// Certificate signature verification failed
49    CertificateSignatureVerificationFailed,
50    /// Certificate is not yet valid
51    CertificateNotYetValid,
52    /// Certificate has expired
53    CertificateExpired,
54    /// No trusted root was found for the chain
55    CertificateNoTrustedRootFound {
56        searched_roots: usize,
57    },
58    /// No root matched by SPKI (cross-signing)
59    CertificateNoRootFoundBySpkiMatching,
60    /// Certificate DER parse failure
61    CertificateParseFailed,
62    /// Certificate list was empty for a RawPublicKey certificate type
63    CertificateEmptyRawPublicKey,
64    /// Unsupported signature algorithm in certificate
65    CertificateUnsupportedSignatureAlgorithm,
66    /// No clock available for certificate validity check (set one via
67    /// [`with_clock`](crate::DefaultCertificateVerifier::with_clock) or enable
68    /// the `std` feature)
69    CertificateClockMissing,
70
71    // ── Crypto ──
72    CryptoError,
73    AeadError,
74
75    // ── General ──
76    NotEstablished,
77}
78
79impl fmt::Display for Error {
80    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
81        write!(f, "{self:?}")
82    }
83}
84
85#[cfg(feature = "std")]
86impl std::error::Error for Error {}