Skip to content

Commit

Permalink
validation: use an extension trait
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed May 10, 2023
1 parent 02d96b9 commit 42400d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/rust/cryptography-x509-validation/src/certificate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is dual licensed under the terms of the Apache License, Version
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.

/// Extensional traits and functionality for certificates.
use cryptography_x509::{certificate::Certificate, extensions::Extensions};

pub(crate) trait CertificateExt: private::Sealed {
fn extensions<'a>(&'a self) -> Result<Option<Extensions<'a>>, asn1::ObjectIdentifier>;
}

impl CertificateExt for Certificate<'_> {
fn extensions<'a>(&'a self) -> Result<Option<Extensions<'a>>, asn1::ObjectIdentifier> {
self.tbs_cert.extensions()
}
}

mod private {
pub(crate) trait Sealed {}

impl Sealed for cryptography_x509::certificate::Certificate<'_> {}
}
1 change: 1 addition & 0 deletions src/rust/cryptography-x509-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#![forbid(unsafe_code)]

pub mod certificate;
pub mod extensions;
pub mod policy;
pub mod trust_store;
Expand Down

0 comments on commit 42400d5

Please sign in to comment.