aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-05 18:46:34 -0700
committerSteven Fackler <[email protected]>2016-11-05 18:46:34 -0700
commit96a5ccfc6b69a6038ee2217551e041ab8275ab4c (patch)
tree9477892f899a5467574102e64e62c1d9bf6d2095 /openssl/src
parentRe-adjust BigNum API (diff)
downloadrust-openssl-96a5ccfc6b69a6038ee2217551e041ab8275ab4c.tar.xz
rust-openssl-96a5ccfc6b69a6038ee2217551e041ab8275ab4c.zip
Implement Pkcs12 via type_!
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/pkcs12.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/openssl/src/pkcs12.rs b/openssl/src/pkcs12.rs
index 8c884e7f..1ef0bf3f 100644
--- a/openssl/src/pkcs12.rs
+++ b/openssl/src/pkcs12.rs
@@ -10,19 +10,10 @@ use {cvt, cvt_p};
use pkey::PKey;
use error::ErrorStack;
use x509::X509;
-use types::OpenSslType;
+use types::{OpenSslType, OpenSslTypeRef};
use stack::Stack;
-/// A PKCS #12 archive.
-pub struct Pkcs12(*mut ffi::PKCS12);
-
-impl Drop for Pkcs12 {
- fn drop(&mut self) {
- unsafe {
- ffi::PKCS12_free(self.0);
- }
- }
-}
+type_!(Pkcs12, Pkcs12Ref, ffi::PKCS12, ffi::PKCS12_free);
impl Pkcs12 {
/// Deserializes a `Pkcs12` structure from DER-encoded data.
@@ -35,7 +26,9 @@ impl Pkcs12 {
Ok(Pkcs12(p12))
}
}
+}
+impl Pkcs12Ref {
/// Extracts the contents of the `Pkcs12`.
pub fn parse(&self, pass: &str) -> Result<ParsedPkcs12, ErrorStack> {
unsafe {
@@ -45,7 +38,11 @@ impl Pkcs12 {
let mut cert = ptr::null_mut();
let mut chain = ptr::null_mut();
- try!(cvt(ffi::PKCS12_parse(self.0, pass.as_ptr(), &mut pkey, &mut cert, &mut chain)));
+ try!(cvt(ffi::PKCS12_parse(self.as_ptr(),
+ pass.as_ptr(),
+ &mut pkey,
+ &mut cert,
+ &mut chain)));
let pkey = PKey::from_ptr(pkey);
let cert = X509::from_ptr(cert);