mls_rs_identity_x509/
error.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// Copyright by contributors to this project.
3// SPDX-License-Identifier: (Apache-2.0 OR MIT)
4
5use mls_rs_core::{error::AnyError, identity::CredentialType};
6
7#[derive(Debug)]
8#[cfg_attr(feature = "std", derive(thiserror::Error))]
9pub enum X509IdentityError {
10    #[cfg_attr(feature = "std", error("unsupported credential type {0:?}"))]
11    UnsupportedCredentialType(CredentialType),
12    #[cfg_attr(
13        feature = "std",
14        error("signing identity public key does not match the leaf certificate")
15    )]
16    SignatureKeyMismatch,
17    #[cfg_attr(feature = "std", error("invalid offset within certificate chain"))]
18    InvalidOffset,
19    #[cfg_attr(feature = "std", error("empty certificate chain"))]
20    EmptyCertificateChain,
21    #[cfg_attr(feature = "std", error(transparent))]
22    X509ReaderError(AnyError),
23    #[cfg_attr(feature = "std", error(transparent))]
24    IdentityExtractorError(AnyError),
25    #[cfg_attr(feature = "std", error(transparent))]
26    X509ValidationError(AnyError),
27}
28
29impl mls_rs_core::error::IntoAnyError for X509IdentityError {
30    #[cfg(feature = "std")]
31    fn into_dyn_error(self) -> Result<Box<dyn std::error::Error + Send + Sync>, Self> {
32        Ok(self.into())
33    }
34}