aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/x509
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-10-29 14:02:26 -0700
committerSteven Fackler <[email protected]>2016-10-29 14:02:26 -0700
commit4c7a5a418ee6a71f26fb6cc720a36b5bca6f3376 (patch)
treec32d680e94790ac37de8e6a534d45229cec52000 /openssl/src/x509
parentMake verification unconditionally exposed internally (diff)
downloadrust-openssl-4c7a5a418ee6a71f26fb6cc720a36b5bca6f3376.tar.xz
rust-openssl-4c7a5a418ee6a71f26fb6cc720a36b5bca6f3376.zip
Implement client and server connectors
Diffstat (limited to 'openssl/src/x509')
-rw-r--r--openssl/src/x509/mod.rs29
1 files changed, 25 insertions, 4 deletions
diff --git a/openssl/src/x509/mod.rs b/openssl/src/x509/mod.rs
index cc6b73bb..9fd6812a 100644
--- a/openssl/src/x509/mod.rs
+++ b/openssl/src/x509/mod.rs
@@ -1,4 +1,5 @@
use libc::{c_char, c_int, c_long, c_ulong, c_void};
+use std::borrow::Borrow;
use std::cmp;
use std::collections::HashMap;
use std::error::Error;
@@ -447,6 +448,17 @@ impl X509Ref {
}
}
+impl ToOwned for X509Ref {
+ type Owned = X509;
+
+ fn to_owned(&self) -> X509 {
+ unsafe {
+ compat::X509_up_ref(self.as_ptr());
+ X509::from_ptr(self.as_ptr())
+ }
+ }
+}
+
/// An owned public key certificate.
pub struct X509(*mut ffi::X509);
@@ -491,10 +503,7 @@ impl Deref for X509 {
impl Clone for X509 {
fn clone(&self) -> X509 {
- unsafe {
- compat::X509_up_ref(self.as_ptr());
- X509::from_ptr(self.as_ptr())
- }
+ self.to_owned()
}
}
@@ -504,6 +513,18 @@ impl Drop for X509 {
}
}
+impl AsRef<X509Ref> for X509 {
+ fn as_ref(&self) -> &X509Ref {
+ &*self
+ }
+}
+
+impl Borrow<X509Ref> for X509 {
+ fn borrow(&self) -> &X509Ref {
+ &*self
+ }
+}
+
pub struct X509NameRef(Opaque);
impl X509NameRef {