diff options
| author | Steven Fackler <[email protected]> | 2018-09-15 14:22:51 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-09-15 14:22:51 -0700 |
| commit | a01979cfdcf61769ec777bbb01c17d18d59b153f (patch) | |
| tree | f39cf232461c9cc708850c8df3d8300d595a53a0 /openssl/src/ssl/callbacks.rs | |
| parent | Release openssl 0.10.12 (diff) | |
| parent | Support the client hello callback (diff) | |
| download | rust-openssl-a01979cfdcf61769ec777bbb01c17d18d59b153f.tar.xz rust-openssl-a01979cfdcf61769ec777bbb01c17d18d59b153f.zip | |
Merge pull request #995 from sfackler/client-hello
Support the client hello callback
Diffstat (limited to 'openssl/src/ssl/callbacks.rs')
| -rw-r--r-- | openssl/src/ssl/callbacks.rs | 29 |
1 files changed, 28 insertions, 1 deletions
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<F>( + ssl: *mut ffi::SSL, + al: *mut c_int, + arg: *mut c_void, +) -> c_int +where + F: Fn(&mut SslRef, &mut SslAlert) -> Result<ClientHelloResponse, ErrorStack> + + '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 + } + } +} |