diff options
| author | Manuel Schölling <[email protected]> | 2015-03-19 10:15:02 +0100 |
|---|---|---|
| committer | Manuel Schölling <[email protected]> | 2015-04-03 14:34:24 +0200 |
| commit | 632d8398cfd9a3ab146d3208200cbe69018fc4b1 (patch) | |
| tree | 6fd120ec844a1dcb2ee3c173c89a96542c9213b2 /openssl/src/ssl/mod.rs | |
| parent | Change SslVerifyMode to bitflags and add SSL_VERIFY_FAIL_IF_NO_PEER_CERT (diff) | |
| download | rust-openssl-632d8398cfd9a3ab146d3208200cbe69018fc4b1.tar.xz rust-openssl-632d8398cfd9a3ab146d3208200cbe69018fc4b1.zip | |
Add ability to load private keys from files and use raw keys and certificates for SslContext
Diffstat (limited to 'openssl/src/ssl/mod.rs')
| -rw-r--r-- | openssl/src/ssl/mod.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index fd2b3345..578cfcd5 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -22,6 +22,7 @@ use bio::{MemBio}; use ffi; use ssl::error::{SslError, SslSessionClosed, StreamError, OpenSslErrors}; use x509::{X509StoreContext, X509FileType, X509}; +use crypto::pkey::PKey; pub mod error; #[cfg(test)] @@ -400,6 +401,14 @@ impl SslContext { }) } + /// Specifies the certificate + pub fn set_certificate(&mut self, cert: &X509) -> Option<SslError> { + wrap_ssl_result( + unsafe { + ffi::SSL_CTX_use_certificate(*self.ctx, cert.get_handle()) + }) + } + /// Specifies the file that contains private key pub fn set_private_key_file(&mut self, file: &Path, file_type: X509FileType) -> Option<SslError> { @@ -410,6 +419,22 @@ impl SslContext { }) } + /// Specifies the private key + pub fn set_private_key(&mut self, key: &PKey) -> Option<SslError> { + wrap_ssl_result( + unsafe { + ffi::SSL_CTX_use_PrivateKey(*self.ctx, key.get_handle()) + }) + } + + /// Check consistency of private key and certificate + pub fn check_private_key(&mut self) -> Option<SslError> { + wrap_ssl_result( + unsafe { + ffi::SSL_CTX_check_private_key(*self.ctx) + }) + } + pub fn set_cipher_list(&mut self, cipher_list: &str) -> Option<SslError> { wrap_ssl_result( unsafe { |