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    #[error(transparent)]
21    JsonWebToken(#[from] rusty_jwt_tools::jsonwebtoken::errors::Error),
22    /// Invalid/incomplete certificate
23    #[error(transparent)]
24    InvalidCertificate(#[from] CertificateError),
25}
26
27/// Given x509 certificate is invalid and does not follow Wire's format
28#[derive(Debug, thiserror::Error)]
29pub enum CertificateError {
30    /// Client ID is not in a valid format
31    #[error("Client ID is not in a valid format")]
32    InvalidClientId,
33    /// ClientId does not match expected one
34    #[error("ClientId does not match expected one")]
35    ClientIdMismatch,
36    /// Display name does not match expected one
37    #[error("Display name does not match expected one")]
38    DisplayNameMismatch,
39    /// Handle does not match expected one
40    #[error("Handle does not match expected one")]
41    HandleMismatch,
42    /// Domain does not match expected one
43    #[error("Domain does not match expected one")]
44    DomainMismatch,
45    /// DisplayName is missing from the certificate
46    #[error("DisplayName is missing from the certificate")]
47    MissingDisplayName,
48    /// Handle is missing from the certificate
49    #[error("Handle is missing from the certificate")]
50    MissingHandle,
51    /// Domain is missing from the certificate
52    #[error("Domain is missing from the certificate")]
53    MissingDomain,
54    /// ClientId is missing from the certificate
55    #[error("ClientId is missing from the certificate")]
56    MissingClientId,
57    /// X509 lacks required standard fields
58    #[error("X509 lacks required standard fields")]
59    InvalidFormat,
60    /// Certificate algorithm does not match the one of the signing keypair
61    #[error("Certificate algorithm does not match the one of the signing keypair")]
62    AlgorithmMismatch,
63    /// Certificate public key does not match the one in the signing keypair
64    #[error("Certificate public key does not match the one in the signing keypair")]
65    KeyMismatch,
66    /// The signing keypair could not be parsed for the expected signature algorithm
67    #[error("The signing keypair could not be parsed for the expected signature algorithm")]
68    InvalidSigningKeypair,
69    /// Advertised public key is not supported
70    #[error("Advertised public key is not supported")]
71    UnsupportedPublicKey,
72    /// Validation error
73    #[error(transparent)]
74    Validation(#[from] crate::validation::Error),
75    /// DER error
76    #[error(transparent)]
77    Der(#[from] spki::der::Error),
78    /// UTF-8 error
79    #[error(transparent)]
80    Utf8(#[from] std::str::Utf8Error),
81    /// ACME error
82    #[error(transparent)]
83    Acme(#[from] crate::acme::Error),
84    /// JWT error
85    #[error(transparent)]
86    RustyJwtError(#[from] RustyJwtError),
87    /// jsonwebtoken error
88    #[error(transparent)]
89    JsonWebToken(#[from] rusty_jwt_tools::jsonwebtoken::errors::Error),
90}