aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-04-13 12:55:35 -0700
committerSteven Fackler <[email protected]>2016-04-13 12:55:35 -0700
commit9a482d9dd05978f60aa0a3460c74ecd68f537ac9 (patch)
treef10caf454a8a0bf806c8c1da4b5ee6f387691fae
parentMerge pull request #376 from kcking/kcking-copy-pkey-using-der (diff)
parentAdd ability to set session ID context on an SSL context (diff)
downloadrust-openssl-9a482d9dd05978f60aa0a3460c74ecd68f537ac9.tar.xz
rust-openssl-9a482d9dd05978f60aa0a3460c74ecd68f537ac9.zip
Merge pull request #379 from rix0rrr/add-context-id
Add ability to set session ID context on an SSL context
-rw-r--r--openssl-sys/src/lib.rs1
-rw-r--r--openssl/src/ssl/mod.rs14
2 files changed, 15 insertions, 0 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index 85f434ae..36a736b9 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -675,6 +675,7 @@ extern "C" {
pub fn SSL_CTX_set_ex_data(ctx: *mut SSL_CTX, idx: c_int, data: *mut c_void)
-> c_int;
pub fn SSL_CTX_get_ex_data(ctx: *mut SSL_CTX, idx: c_int) -> *mut c_void;
+ pub fn SSL_CTX_set_session_id_context(ssl: *mut SSL_CTX, sid_ctx: *const c_uchar, sid_ctx_len: c_uint) -> c_int;
pub fn SSL_CTX_use_certificate_file(ctx: *mut SSL_CTX, cert_file: *const c_char, file_type: c_int) -> c_int;
pub fn SSL_CTX_use_certificate_chain_file(ctx: *mut SSL_CTX, cert_chain_file: *const c_char, file_type: c_int) -> c_int;
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 7b5cf492..71a6ccda 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -621,6 +621,20 @@ impl SslContext {
})
}
+ /// Set the context identifier for sessions
+ ///
+ /// This value identifies the server's session cache to a clients, telling them when they're
+ /// able to reuse sessions. Should be set to a unique value per server, unless multiple servers
+ /// share a session cache.
+ ///
+ /// This value should be set when using client certificates, or each request will fail
+ /// handshake and need to be restarted.
+ pub fn set_session_id_context(&mut self, sid_ctx: &[u8]) -> Result<(), SslError> {
+ wrap_ssl_result(unsafe {
+ ffi::SSL_CTX_set_session_id_context(self.ctx, sid_ctx.as_ptr(), sid_ctx.len() as u32)
+ })
+ }
+
/// Specifies the file that contains certificate
pub fn set_certificate_file<P: AsRef<Path>>(&mut self,
file: P,