aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/callbacks.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-09-15 13:29:18 -0700
committerSteven Fackler <[email protected]>2018-09-15 13:29:18 -0700
commit22231d7547465eefc8a1bbb3ed439af24bb6970e (patch)
treef39cf232461c9cc708850c8df3d8300d595a53a0 /openssl/src/ssl/callbacks.rs
parentRelease openssl 0.10.12 (diff)
downloadrust-openssl-22231d7547465eefc8a1bbb3ed439af24bb6970e.tar.xz
rust-openssl-22231d7547465eefc8a1bbb3ed439af24bb6970e.zip
Support the client hello callback
Diffstat (limited to 'openssl/src/ssl/callbacks.rs')
-rw-r--r--openssl/src/ssl/callbacks.rs29
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
+ }
+ }
+}