From 36a667be49075ddea193214b55f76f6186c6f64a Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Tue, 19 Jan 2016 22:04:18 -0500 Subject: x509: impl Clone using references & CRYPTO_add() --- openssl/src/x509/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'openssl/src/x509/mod.rs') diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs index ffd478ef..f31de89b 100644 --- a/openssl/src/x509/mod.rs +++ b/openssl/src/x509/mod.rs @@ -507,6 +507,20 @@ impl<'ctx> X509<'ctx> { } } +extern "C" { + fn rust_X509_clone(x509: *mut ffi::X509); +} + +impl<'ctx> Clone for X509<'ctx> { + fn clone(&self) -> X509<'ctx> { + unsafe { rust_X509_clone(self.handle) } + /* FIXME: given that we now have refcounting control, 'owned' should be uneeded, the 'ctx + * is probably also uneeded. We can remove both to condense the x509 api quite a bit + */ + X509::new(self.handle, true) + } +} + impl<'ctx> Drop for X509<'ctx> { fn drop(&mut self) { if self.owned { -- cgit v1.2.3