Skip to content

Commit 866ce4d

Browse files
committed
update signature of ClientHello Callback
1 parent d4bfe94 commit 866ce4d

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

openssl/src/ssl/callbacks.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::ssl::{
2929
#[cfg(boringssl)]
3030
use crate::ssl::{ClientHello, SelectCertError};
3131
#[cfg(ossl111)]
32-
use crate::ssl::{ClientHelloResponse, ExtensionContext};
32+
use crate::ssl::{ClientHelloError, ExtensionContext};
3333
#[cfg(ossl111)]
3434
use crate::util::ForeignTypeRefExt;
3535
#[cfg(ossl111)]
@@ -688,7 +688,7 @@ pub unsafe extern "C" fn raw_client_hello<F>(
688688
arg: *mut c_void,
689689
) -> c_int
690690
where
691-
F: Fn(&mut SslRef, &mut SslAlert) -> Result<ClientHelloResponse, ErrorStack>
691+
F: Fn(&mut SslRef, &mut SslAlert) -> Result<(), ClientHelloError>
692692
+ 'static
693693
+ Sync
694694
+ Send,
@@ -700,11 +700,8 @@ where
700700
let r = (*callback)(ssl, &mut alert);
701701
*al = alert.0;
702702
match r {
703-
Ok(c) => c.0,
704-
Err(e) => {
705-
e.put();
706-
ffi::SSL_CLIENT_HELLO_ERROR
707-
}
703+
Ok(()) => ffi::SSL_CLIENT_HELLO_SUCCESS,
704+
Err(e) => e.0,
708705
}
709706
}
710707

openssl/src/ssl/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -674,20 +674,20 @@ impl AlpnError {
674674
pub const NOACK: AlpnError = AlpnError(ffi::SSL_TLSEXT_ERR_NOACK);
675675
}
676676

677-
/// The result of a client hello callback.
677+
/// An error returned from a client hello callback.
678678
///
679679
/// Requires OpenSSL 1.1.1 or newer.
680680
#[cfg(ossl111)]
681681
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
682-
pub struct ClientHelloResponse(c_int);
682+
pub struct ClientHelloError(c_int);
683683

684684
#[cfg(ossl111)]
685-
impl ClientHelloResponse {
686-
/// Continue the handshake.
687-
pub const SUCCESS: ClientHelloResponse = ClientHelloResponse(ffi::SSL_CLIENT_HELLO_SUCCESS);
685+
impl ClientHelloError {
686+
/// Terminate the connection.
687+
pub const ERROR: ClientHelloError = ClientHelloError(ffi::SSL_CLIENT_HELLO_ERROR);
688688

689689
/// Return from the handshake with an `ErrorCode::WANT_CLIENT_HELLO_CB` error.
690-
pub const RETRY: ClientHelloResponse = ClientHelloResponse(ffi::SSL_CLIENT_HELLO_RETRY);
690+
pub const RETRY: ClientHelloError = ClientHelloError(ffi::SSL_CLIENT_HELLO_RETRY);
691691
}
692692

693693
/// An error returned from a certificate selection callback.
@@ -2085,7 +2085,7 @@ impl SslContextBuilder {
20852085
#[cfg(ossl111)]
20862086
pub fn set_client_hello_callback<F>(&mut self, callback: F)
20872087
where
2088-
F: Fn(&mut SslRef, &mut SslAlert) -> Result<ClientHelloResponse, ErrorStack>
2088+
F: Fn(&mut SslRef, &mut SslAlert) -> Result<(), ClientHelloError>
20892089
+ 'static
20902090
+ Sync
20912091
+ Send,

0 commit comments

Comments
 (0)