Skip to content

Commit

Permalink
feat: impl Error for ClientCertVerifierBuilderError
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored and cpu committed Sep 11, 2023
1 parent 53e9e77 commit b57204d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion rustls/src/webpki/client_verifier_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::sync::Arc;
use core::fmt;
use std::{error::Error as StdError, sync::Arc};

use pki_types::CertificateRevocationListDer;
use webpki::BorrowedCertRevocationList;
Expand Down Expand Up @@ -97,6 +98,17 @@ impl From<CertRevocationListError> for ClientCertVerifierBuilderError {
}
}

impl fmt::Display for ClientCertVerifierBuilderError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NoRootAnchors => write!(f, "no root trust anchors were provided"),
Self::InvalidCrl(e) => write!(f, "provided CRL could not be parsed: {:?}", e),
}
}
}

impl StdError for ClientCertVerifierBuilderError {}

#[cfg(test)]
mod tests {
use crate::server::ClientCertVerifierBuilderError;
Expand Down Expand Up @@ -252,4 +264,17 @@ mod tests {
Err(ClientCertVerifierBuilderError::NoRootAnchors)
));
}

#[test]
fn smoke() {
let all = vec![
ClientCertVerifierBuilderError::NoRootAnchors,
ClientCertVerifierBuilderError::InvalidCrl(crate::CertRevocationListError::ParseError),
];

for err in all {
let _ = format!("{:?}", err);
let _ = format!("{}", err);
}
}
}

0 comments on commit b57204d

Please sign in to comment.