Skip to main content

wire_e2e_identity/acquisition/
error.rs

1use rusty_jwt_tools::prelude::RustyJwtError;
2
3use crate::pki_env::hooks::PkiEnvironmentHooksError;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    #[error("a PKI environment hook failed")]
8    HookFailed(#[from] PkiEnvironmentHooksError),
9    #[error("JSON parsing failed")]
10    Json(#[from] serde_json::Error),
11    #[error("HTTP response is missing header '{0}'")]
12    MissingHeader(&'static str),
13    #[error(transparent)]
14    Acme(#[from] crate::acme::RustyAcmeError),
15    #[error(transparent)]
16    RustyJwtError(#[from] RustyJwtError),
17    /// Invalid/incomplete certificate
18    #[error(transparent)]
19    InvalidCertificate(#[from] CertificateError),
20}
21
22/// Given x509 certificate is invalid and does not follow Wire's format
23#[derive(Debug, thiserror::Error)]
24pub enum CertificateError {
25    /// Client ID is not in a valid format
26    #[error("Client ID is not in a valid format")]
27    InvalidClientId,
28    /// ClientId does not match expected one
29    #[error("ClientId does not match expected one")]
30    ClientIdMismatch,
31    /// Display name does not match expected one
32    #[error("Display name does not match expected one")]
33    DisplayNameMismatch,
34    /// Handle does not match expected one
35    #[error("Handle does not match expected one")]
36    HandleMismatch,
37    /// Domain does not match expected one
38    #[error("Domain does not match expected one")]
39    DomainMismatch,
40    /// DisplayName is missing from the certificate
41    #[error("DisplayName is missing from the certificate")]
42    MissingDisplayName,
43    /// Handle is missing from the certificate
44    #[error("Handle is missing from the certificate")]
45    MissingHandle,
46    /// Domain is missing from the certificate
47    #[error("Domain is missing from the certificate")]
48    MissingDomain,
49    /// ClientId is missing from the certificate
50    #[error("ClientId is missing from the certificate")]
51    MissingClientId,
52    /// X509 lacks required standard fields
53    #[error("X509 lacks required standard fields")]
54    InvalidFormat,
55    /// Certificate algorithm does not match the one of the signing keypair
56    #[error("Certificate algorithm does not match the one of the signing keypair")]
57    AlgorithmMismatch,
58    /// Certificate public key does not match the one in the signing keypair
59    #[error("Certificate public key does not match the one in the signing keypair")]
60    KeyMismatch,
61    /// Advertised public key is not supported
62    #[error("Advertised public key is not supported")]
63    UnsupportedPublicKey,
64    /// X509Check error
65    #[error("transparent")]
66    X509Check(#[from] crate::x509_check::RustyX509CheckError),
67    /// DER error
68    #[error(transparent)]
69    Der(#[from] spki::der::Error),
70    /// UTF-8 error
71    #[error(transparent)]
72    Utf8(#[from] std::str::Utf8Error),
73    /// ACME error
74    #[error(transparent)]
75    Acme(#[from] crate::acme::RustyAcmeError),
76    /// JWT error
77    #[error(transparent)]
78    RustyJwtError(#[from] RustyJwtError),
79    /// jwt-simple error
80    #[error(transparent)]
81    JwtSimple(#[from] jwt_simple::Error),
82}