From 06ba41ad47e55d8075d74ee0d3041fbd6ee206b5 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 22 Feb 2015 15:44:02 -0600 Subject: add support for SSL_CTX_set_options and SSL_CTX_get_options fixes #168 --- openssl/src/ssl/mod.rs | 12 ++++++++++++ openssl/src/ssl/tests.rs | 14 ++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'openssl/src') diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 5d3549ff..fe04e8ec 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -279,6 +279,18 @@ impl SslContext { ffi::SSL_CTX_set_cipher_list(*self.ctx, cipher_list.as_ptr()) }) } + + pub fn set_options(&mut self, option: c_long) -> c_long { + unsafe { + ffi::SSL_CTX_set_options(*self.ctx, option) + } + } + + pub fn get_options(&mut self) -> c_long { + unsafe { + ffi::SSL_CTX_get_options(*self.ctx) + } + } } #[allow(dead_code)] diff --git a/openssl/src/ssl/tests.rs b/openssl/src/ssl/tests.rs index 4bb3c2ca..c5e9c5e9 100644 --- a/openssl/src/ssl/tests.rs +++ b/openssl/src/ssl/tests.rs @@ -174,6 +174,20 @@ fn test_verify_callback_data() { } } +#[test] +fn test_get_ctx_options() { + let mut ctx = SslContext::new(Sslv23).unwrap(); + ctx.get_options(); +} + +#[test] +fn test_set_ctx_options() { + let mut ctx = SslContext::new(Sslv23).unwrap(); + let start_opts = ctx.get_options(); + let ssl_op_no_sslv3 = 0x02000000; + let res = ctx.set_options(ssl_op_no_sslv3); + assert_eq!(res, start_opts | ssl_op_no_sslv3); +} #[test] fn test_write() { -- cgit v1.2.3