implement get/set ssl context

This commit is contained in:
Geoffroy Couprie 2015-11-22 20:01:41 +01:00
parent cb4263f91e
commit dba3a0ced2
2 changed files with 9 additions and 0 deletions

View File

@ -534,6 +534,7 @@ extern "C" {
pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int;
pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int;
pub fn SSL_get_SSL_CTX(ssl: *mut SSL) -> *mut SSL_CTX;
pub fn SSL_set_SSL_CTX(ssl: *mut SSL, ctx: *mut SSL_CTX) -> *mut SSL_CTX;
pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const COMP_METHOD;
pub fn SSL_get_peer_certificate(ssl: *mut SSL) -> *mut X509;
pub fn SSL_get_ssl_method(ssl: *mut SSL) -> *const SSL_METHOD;

View File

@ -982,6 +982,14 @@ impl Ssl {
}
}
pub fn set_ssl_context(&self, ctx: &SslContext) -> SslContext {
SslContext { ctx: unsafe { ffi::SSL_set_SSL_CTX(self.ssl, ctx.ctx) } }
}
pub fn get_ssl_context(&self) -> SslContext {
let ssl_ctx = unsafe { ffi::SSL_get_SSL_CTX(self.ssl) };
SslContext { ctx: ssl_ctx }
}
}
macro_rules! make_LibSslError {