Skip to content

Commit

Permalink
Expose WebPKIVerifier under dangerous feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gorup authored and ctz committed Nov 23, 2019
1 parent beb02de commit 1d8114c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target/
*.gcda
*.gcno
*.info
sslkeylogfile.txt
2 changes: 1 addition & 1 deletion rustls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ mod quic {

#[cfg(feature = "dangerous_configuration")]
pub use crate::verify::{ServerCertVerifier, ServerCertVerified,
ClientCertVerifier, ClientCertVerified};
ClientCertVerifier, ClientCertVerified, WebPKIVerifier};
#[cfg(feature = "dangerous_configuration")]
pub use crate::client::danger::DangerousClientConfig;

8 changes: 8 additions & 0 deletions rustls/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,18 @@ pub trait ClientCertVerifier : Send + Sync {
presented_certs: &[Certificate]) -> Result<ClientCertVerified, TLSError>;
}

/// Default `ServerCertVerifier`, see the trait impl for more information.
pub struct WebPKIVerifier {
/// time provider
pub time: fn() -> Result<webpki::Time, TLSError>,
}

impl ServerCertVerifier for WebPKIVerifier {
/// Will verify the certificate is valid in the following ways:
/// - Signed by a trusted `RootCertStore` CA
/// - Not Expired
/// - Valid for DNS entry
/// - OCSP data is present
fn verify_server_cert(&self,
roots: &RootCertStore,
presented_certs: &[Certificate],
Expand All @@ -118,6 +125,7 @@ impl ServerCertVerifier for WebPKIVerifier {
}

impl WebPKIVerifier {
/// Create a new `WebPKIVerifier`
pub fn new() -> WebPKIVerifier {
WebPKIVerifier {
time: try_now,
Expand Down

0 comments on commit 1d8114c

Please sign in to comment.