diff options
| author | David Weinstein <[email protected]> | 2016-08-03 15:56:38 -0400 |
|---|---|---|
| committer | David Weinstein <[email protected]> | 2016-08-17 01:23:54 -0400 |
| commit | f9cd4bff1f371336bc4f69298713069ce09825b7 (patch) | |
| tree | 4c29fc159904c468aad4a50ea15e8eebd95ff746 /openssl/src/asn1 | |
| parent | Merge pull request #440 from dweinstein/openssl-mirror (diff) | |
| download | rust-openssl-f9cd4bff1f371336bc4f69298713069ce09825b7.tar.xz rust-openssl-f9cd4bff1f371336bc4f69298713069ce09825b7.zip | |
Progress on asn1 expiry
- Use MemBio and implement `Display` for Asn1Time
- Tweak doc for asn1 `not_before`, `not_after`
Diffstat (limited to 'openssl/src/asn1')
| -rw-r--r-- | openssl/src/asn1/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/openssl/src/asn1/mod.rs b/openssl/src/asn1/mod.rs index 7d209775..40b6e0f7 100644 --- a/openssl/src/asn1/mod.rs +++ b/openssl/src/asn1/mod.rs @@ -1,10 +1,12 @@ use libc::c_long; use std::ptr; +use std::fmt; use ffi; use error::ErrorStack; pub struct Asn1Time(*mut ffi::ASN1_TIME); +use bio::MemBio; impl Asn1Time { /// Wraps existing ASN1_TIME and takes ownership @@ -32,6 +34,17 @@ impl Asn1Time { } } +impl fmt::Display for Asn1Time { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mem_bio = try!(MemBio::new()); + let as_str = unsafe { + ffi::ASN1_TIME_print(mem_bio.handle(), self.handle); + String::from_utf8_unchecked(mem_bio.get_buf().to_owned()) + }; + write!(f, "{}", as_str) + } +} + impl Drop for Asn1Time { fn drop(&mut self) { unsafe { ffi::ASN1_TIME_free(self.0) }; |