Commit 608d6558 authored by Steven Fackler's avatar Steven Fackler
Browse files

Add pointers to enforce lifetimes

parent 08ef3b5b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -194,17 +194,26 @@ impl X509StoreContext {
        if ptr.is_null() {
            None
        } else {
            Some(X509 { x509: ptr })
            Some(X509 { ctx: self, x509: ptr })
        }
    }
}

/// A public key certificate
pub struct X509<'ctx> {
    priv ctx: &'ctx X509StoreContext,
    priv x509: *ffi::X509
}

impl<'ctx> X509<'ctx> {
    pub fn subject_name<'a>(&'a self) -> X509Name<'a> {
        let name = unsafe { ffi::X509_get_subject_name(self.x509) };
        X509Name { x509: self, name: name }
    }
}

pub struct X509Name<'x> {
    priv x509: &'x X509<'x>,
    priv name: *ffi::X509_NAME
}