Skip to main content

wire_e2e_identity/acquisition/
error.rs

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