aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/mod.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-03-11 15:36:47 -0700
committerSteven Fackler <[email protected]>2018-03-11 15:36:47 -0700
commit9f5ef88880f6f5a239d223eab5103b7c9c684c64 (patch)
treee7e81b92d156c9e01ee391e488caa2ad317fbc36 /openssl/src/ssl/mod.rs
parentMerge pull request #860 from Ralith/custom-extensions (diff)
downloadrust-openssl-9f5ef88880f6f5a239d223eab5103b7c9c684c64.tar.xz
rust-openssl-9f5ef88880f6f5a239d223eab5103b7c9c684c64.zip
Add a Sync + Send bound to the custom ext type
It's stored inside of the Ssl, so this is probably tecnically necessarly?
Diffstat (limited to 'openssl/src/ssl/mod.rs')
-rw-r--r--openssl/src/ssl/mod.rs39
1 files changed, 26 insertions, 13 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index a18ef3a0..e2a0f156 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1513,20 +1513,29 @@ impl SslContextBuilder {
/// [`SSL_CTX_add_custom_ext`]: https://www.openssl.org/docs/manmaster/man3/SSL_CTX_add_custom_ext.html
#[cfg(all(feature = "v111", ossl111))]
pub fn add_custom_ext<AddFn, ParseFn, T>(
- &mut self, ext_type: u16, context: ExtensionContext, add_cb: AddFn, parse_cb: ParseFn
+ &mut self,
+ ext_type: u16,
+ context: ExtensionContext,
+ add_cb: AddFn,
+ parse_cb: ParseFn,
) -> Result<(), ErrorStack>
- where AddFn: Fn(&mut SslRef, ExtensionContext, Option<(usize, &X509Ref)>)
- -> Result<Option<T>, SslAlert> + 'static + Sync + Send,
- T: AsRef<[u8]> + 'static,
- ParseFn: Fn(&mut SslRef, ExtensionContext, &[u8], Option<(usize, &X509Ref)>)
- -> Result<(), SslAlert> + 'static + Sync + Send,
+ where
+ AddFn: Fn(&mut SslRef, ExtensionContext, Option<(usize, &X509Ref)>) -> Result<Option<T>, SslAlert>
+ + 'static
+ + Sync
+ + Send,
+ T: AsRef<[u8]> + 'static + Sync + Send,
+ ParseFn: Fn(&mut SslRef, ExtensionContext, &[u8], Option<(usize, &X509Ref)>) -> Result<(), SslAlert>
+ + 'static
+ + Sync
+ + Send,
{
let ret = unsafe {
let add_cb = Box::new(add_cb);
ffi::SSL_CTX_set_ex_data(
self.as_ptr(),
get_callback_idx::<AddFn>(),
- Box::into_raw(add_cb) as *mut _
+ Box::into_raw(add_cb) as *mut _,
);
let parse_cb = Box::new(parse_cb);
@@ -1536,12 +1545,16 @@ impl SslContextBuilder {
Box::into_raw(parse_cb) as *mut _,
);
- ffi::SSL_CTX_add_custom_ext(self.as_ptr(), ext_type as c_uint, context.bits(),
- Some(raw_custom_ext_add::<AddFn, T>),
- Some(raw_custom_ext_free::<T>),
- ptr::null_mut(),
- Some(raw_custom_ext_parse::<ParseFn>),
- ptr::null_mut())
+ ffi::SSL_CTX_add_custom_ext(
+ self.as_ptr(),
+ ext_type as c_uint,
+ context.bits(),
+ Some(raw_custom_ext_add::<AddFn, T>),
+ Some(raw_custom_ext_free::<T>),
+ ptr::null_mut(),
+ Some(raw_custom_ext_parse::<ParseFn>),
+ ptr::null_mut(),
+ )
};
if ret == 1 {
Ok(())