diff options
Diffstat (limited to 'openssl/src/ssl')
| -rw-r--r-- | openssl/src/ssl/mod.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 9a477993..16bc386b 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -762,6 +762,31 @@ impl SslContext { } } +impl SslContextRef { + /// Returns the certificate associated with this `SslContext`, if present. + pub fn certificate(&self) -> Option<&X509Ref> { + unsafe { + let ptr = ffi::SSL_CTX_get0_certificate(self.as_ptr()); + if ptr.is_null() { + None + } else { + Some(X509Ref::from_ptr(ptr)) + } + } + } + + /// Returns the private key associated with this `SslContext`, if present. + pub fn private_key(&self) -> Option<&PKeyRef> { + unsafe { + let ptr = ffi::SSL_CTX_get0_privatekey(self.as_ptr()); + if ptr.is_null() { + None + } else { + Some(PKeyRef::from_ptr(ptr)) + } + } + } +} pub struct CipherBits { /// The number of secret bits used for the cipher. @@ -955,6 +980,30 @@ impl SslRef { } } + /// Returns the certificate associated with this `Ssl`, if present. + pub fn certificate(&self) -> Option<&X509Ref> { + unsafe { + let ptr = ffi::SSL_get_certificate(self.as_ptr()); + if ptr.is_null() { + None + } else { + Some(X509Ref::from_ptr(ptr)) + } + } + } + + /// Returns the private key associated with this `Ssl`, if present. + pub fn private_key(&self) -> Option<&PKeyRef> { + unsafe { + let ptr = ffi::SSL_get_privatekey(self.as_ptr()); + if ptr.is_null() { + None + } else { + Some(PKeyRef::from_ptr(ptr)) + } + } + } + /// Returns the name of the protocol used for the connection, e.g. "TLSv1.2", "SSLv3", etc. pub fn version(&self) -> &'static str { let version = unsafe { |