From 608d6558dea3962f796f9154f0eb2b1dc4390e54 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 8 Dec 2013 22:12:49 -0800 Subject: [PATCH] Add pointers to enforce lifetimes --- lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib.rs b/lib.rs index 60ac5905..4d0591a5 100644 --- a/lib.rs +++ b/lib.rs @@ -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 }