wire_e2e_identity/acme/
error.rs

1/// Wrapper over a [Result] with a [RustyAcmeError] error
2pub type RustyAcmeResult<T> = Result<T, RustyAcmeError>;
3
4/// All errors which [crate::RustyAcme] might throw
5#[derive(Debug, thiserror::Error)]
6pub enum RustyAcmeError {
7    /// Invalid Json representation
8    #[error(transparent)]
9    JsonError(#[from] serde_json::Error),
10    /// Invalid URL
11    #[error(transparent)]
12    UrlError(#[from] url::ParseError),
13    /// Error while building a JWT
14    #[error(transparent)]
15    JwtError(#[from] rusty_jwt_tools::prelude::RustyJwtError),
16    /// Error related to various X509 processing facilities/tools/checks
17    #[error(transparent)]
18    X509CheckError(#[from] crate::acme::x509_check::RustyX509CheckError),
19    /// Failed mapping an ASN.1 ObjectIdentifier
20    #[error(transparent)]
21    OidError(#[from] x509_cert::der::oid::Error),
22    /// Failed mapping a DER certificate
23    #[error(transparent)]
24    DerError(#[from] x509_cert::der::Error),
25    /// Error while parsing a PEM document
26    #[error(transparent)]
27    PemError(#[from] pem::PemError),
28    /// Error while handling a JWT
29    #[error(transparent)]
30    RawJwtError(#[from] jwt_simple::Error),
31    /// Error with hand-rolled signature
32    #[error(transparent)]
33    SignatureError(#[from] signature::Error),
34    /// We have done something terribly wrong
35    #[error("We have done something terribly wrong and it needs to be fixed")]
36    ImplementationError,
37    /// Mostly related to WASM support
38    #[error("Requested functionality is not supported for the moment")]
39    NotSupported,
40    /// This library has been used the wrong way by users
41    #[error("This library has been used the wrong way by users because {0}")]
42    ClientImplementationError(&'static str),
43    /// Smallstep ACME server is not correctly implemented
44    #[error("Incorrect response from ACME server because {0}")]
45    SmallstepImplementationError(&'static str),
46    /// Error while processing an account
47    #[error(transparent)]
48    AccountError(#[from] crate::acme::account::AcmeAccountError),
49    /// Error while processing an order
50    #[error(transparent)]
51    OrderError(#[from] crate::acme::order::AcmeOrderError),
52    /// Error while processing an authorization
53    #[error(transparent)]
54    AuthzError(#[from] crate::acme::authz::AcmeAuthzError),
55    /// Error while validating a challenge
56    #[error(transparent)]
57    ChallengeError(#[from] crate::acme::chall::AcmeChallError),
58    /// Error while finalizing an order
59    #[error(transparent)]
60    FinalizeError(#[from] crate::acme::finalize::AcmeFinalizeError),
61    /// UTF-8 parsing error
62    #[error(transparent)]
63    Utf8(#[from] std::str::Utf8Error),
64    /// Invalid/incomplete certificate
65    #[error(transparent)]
66    InvalidCertificate(#[from] CertificateError),
67}
68
69/// Given x509 certificate is invalid and does not follow Wire's format
70#[derive(Debug, thiserror::Error)]
71pub enum CertificateError {
72    /// ClientId does not match expected one
73    #[error("ClientId does not match expected one")]
74    ClientIdMismatch,
75    /// Display name does not match expected one
76    #[error("Display name does not match expected one")]
77    DisplayNameMismatch,
78    /// Handle does not match expected one
79    #[error("Handle does not match expected one")]
80    HandleMismatch,
81    /// Domain does not match expected one
82    #[error("Domain does not match expected one")]
83    DomainMismatch,
84    /// DisplayName is missing from the certificate
85    #[error("DisplayName is missing from the certificate")]
86    MissingDisplayName,
87    /// Handle is missing from the certificate
88    #[error("Handle is missing from the certificate")]
89    MissingHandle,
90    /// Domain is missing from the certificate
91    #[error("Domain is missing from the certificate")]
92    MissingDomain,
93    /// ClientId is missing from the certificate
94    #[error("ClientId is missing from the certificate")]
95    MissingClientId,
96    /// X509 lacks required standard fields
97    #[error("X509 lacks required standard fields")]
98    InvalidFormat,
99    /// Advertised public key does not match algorithm
100    #[error("Advertised public key does not match algorithm")]
101    InvalidPublicKey,
102    /// Advertised public key is not supported
103    #[error("Advertised public key is not supported")]
104    UnsupportedPublicKey,
105}