From 22231d7547465eefc8a1bbb3ed439af24bb6970e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 15 Sep 2018 13:29:18 -0700 Subject: Support the client hello callback --- openssl/src/ssl/callbacks.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'openssl/src/ssl/callbacks.rs') diff --git a/openssl/src/ssl/callbacks.rs b/openssl/src/ssl/callbacks.rs index daa58a4e..18aba527 100644 --- a/openssl/src/ssl/callbacks.rs +++ b/openssl/src/ssl/callbacks.rs @@ -23,7 +23,7 @@ use pkey::Params; #[cfg(any(ossl102, libressl261))] use ssl::AlpnError; #[cfg(ossl111)] -use ssl::ExtensionContext; +use ssl::{ExtensionContext, ClientHelloResponse}; use ssl::{SniError, Ssl, SslAlert, SslContext, SslContextRef, SslRef, SslSession, SslSessionRef}; #[cfg(ossl111)] use x509::X509Ref; @@ -655,3 +655,30 @@ where } } } + +#[cfg(ossl111)] +pub unsafe extern "C" fn raw_client_hello( + ssl: *mut ffi::SSL, + al: *mut c_int, + arg: *mut c_void, +) -> c_int +where + F: Fn(&mut SslRef, &mut SslAlert) -> Result + + 'static + + Sync + + Send, +{ + let ssl = SslRef::from_ptr_mut(ssl); + let callback = arg as *const F; + let mut alert = SslAlert(*al); + + let r = (*callback)(ssl, &mut alert); + *al = alert.0; + match r { + Ok(c) => c.0, + Err(e) => { + e.put(); + ffi::SSL_CLIENT_HELLO_ERROR + } + } +} -- cgit v1.2.3