diff options
| author | Steven Fackler <[email protected]> | 2016-08-16 22:34:46 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-08-16 22:34:46 -0700 |
| commit | 82bda28206144752326f89f431d431baebf2c766 (patch) | |
| tree | b102c7dd4590254aa0831bac1f62e32f8ccb625b /openssl/src/x509/mod.rs | |
| parent | Merge pull request #440 from dweinstein/openssl-mirror (diff) | |
| parent | Get rid of use Asn1TimeRef warning for some builds (diff) | |
| download | rust-openssl-82bda28206144752326f89f431d431baebf2c766.tar.xz rust-openssl-82bda28206144752326f89f431d431baebf2c766.zip | |
Merge pull request #436 from dweinstein/asn1_expiration
Add support for getting X509 notBefore, notAfter
Diffstat (limited to 'openssl/src/x509/mod.rs')
| -rw-r--r-- | openssl/src/x509/mod.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index 0cc0eca7..1319b75c 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -11,6 +11,9 @@ use std::marker::PhantomData; use HashTypeInternals; use asn1::Asn1Time; +#[cfg(feature = "x509_expiry")] +use asn1::Asn1TimeRef; + use bio::{MemBio, MemBioSlice}; use crypto::hash; use crypto::hash::Type as HashType; @@ -433,6 +436,28 @@ impl<'a> X509Ref<'a> { } } + /// Returns certificate Not After validity period. + /// Requires the `x509_expiry` feature. + #[cfg(feature = "x509_expiry")] + pub fn not_after<'b>(&'b self) -> Asn1TimeRef<'b> { + unsafe { + let date = ::c_helpers::rust_0_8_X509_get_notAfter(self.0); + assert!(!date.is_null()); + Asn1TimeRef::from_ptr(date) + } + } + + /// Returns certificate Not Before validity period. + /// Requires the `x509_expiry` feature. + #[cfg(feature = "x509_expiry")] + pub fn not_before<'b>(&'b self) -> Asn1TimeRef<'b> { + unsafe { + let date = ::c_helpers::rust_0_8_X509_get_notBefore(self.0); + assert!(!date.is_null()); + Asn1TimeRef::from_ptr(date) + } + } + /// Writes certificate as PEM pub fn to_pem(&self) -> Result<Vec<u8>, ErrorStack> { let mem_bio = try!(MemBio::new()); |