Include underlying error in `CertificateError::Other`

This commit is contained in:
Joseph Birr-Pixton 2023-01-25 12:10:15 +00:00
parent 00d7ac50f9
commit aea27248fd
2 changed files with 10 additions and 8 deletions

View File

@ -3,6 +3,7 @@ use crate::rand;
use std::error::Error as StdError;
use std::fmt;
use std::sync::Arc;
use std::time::SystemTimeError;
/// rustls reports protocol errors using this type.
@ -251,7 +252,14 @@ pub enum CertificateError {
NotValidForName,
/// Any other error.
Other,
///
/// This can be used by custom verifiers to expose the underlying error
/// (where they are not better described by the more specific errors
/// above).
///
/// It is also used by the default verifier in case its error is
/// not covered by the above common cases.
Other(Arc<dyn StdError + Send + Sync>),
}
impl From<CertificateError> for Error {

View File

@ -626,13 +626,7 @@ fn pki_error(error: webpki::Error) -> Error {
InvalidSignatureForPublicKey
| UnsupportedSignatureAlgorithm
| UnsupportedSignatureAlgorithmForPublicKey => CertificateError::BadSignature.into(),
e => {
crate::log::warn!(
"webpki error {:?} being converted to CertificateError::Other",
e
);
CertificateError::Other.into()
}
_ => CertificateError::Other(Arc::new(error)).into(),
}
}