use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Error {
BadDer,
BadDerTime,
CaUsedAsEndEntity,
CertExpired,
CertNotValidForName,
CertNotValidYet,
EndEntityUsedAsCa,
ExtensionValueInvalid,
InvalidCertValidity,
InvalidSignatureForPublicKey,
NameConstraintViolation,
PathLenConstraintViolated,
SignatureAlgorithmMismatch,
RequiredEkuNotFound,
UnknownIssuer,
UnsupportedCertVersion,
MissingOrMalformedExtensions,
UnsupportedCriticalExtension,
UnsupportedSignatureAlgorithmForPublicKey,
UnsupportedSignatureAlgorithm,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
#[cfg(feature = "std")]
impl ::std::error::Error for Error {}
#[non_exhaustive]
pub enum ErrorExt {
Error(Error),
MaximumSignatureChecksExceeded,
MaximumPathBuildCallsExceeded,
}
impl ErrorExt {
pub(crate) fn is_fatal(&self) -> bool {
match self {
Self::Error(_) => false,
Self::MaximumSignatureChecksExceeded | Self::MaximumPathBuildCallsExceeded => true,
}
}
pub(crate) fn into_error_lossy(self) -> Error {
match self {
Self::Error(e) => e,
Self::MaximumSignatureChecksExceeded | Self::MaximumPathBuildCallsExceeded => {
Error::UnknownIssuer
}
}
}
}
impl From<Error> for ErrorExt {
fn from(error: Error) -> Self {
Self::Error(error)
}
}