aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/x509/mod.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-01-19 19:59:00 -0800
committerSteven Fackler <[email protected]>2016-01-19 19:59:00 -0800
commit50bf7a933b52785ac4b5e4621813fcf28e62ddaf (patch)
treecabb93dce85825b5000af015124f8f5444597ee9 /openssl/src/x509/mod.rs
parentFix should_panic check (diff)
parentx509: impl Clone using references & CRYPTO_add() (diff)
downloadrust-openssl-50bf7a933b52785ac4b5e4621813fcf28e62ddaf.tar.xz
rust-openssl-50bf7a933b52785ac4b5e4621813fcf28e62ddaf.zip
Merge pull request #336 from jmesmon/x509-pky-clone
impl Clone for PKey and X509 by using their 'references' member
Diffstat (limited to 'openssl/src/x509/mod.rs')
-rw-r--r--openssl/src/x509/mod.rs14
1 files changed, 14 insertions, 0 deletions
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 {