Simpler setter for verify with data
There is no need in wrapping function in option as there is no sense in providing data without function.
This commit is contained in:
parent
fbb359720b
commit
4d3f9e0520
|
|
@ -222,13 +222,15 @@ impl SslContext {
|
||||||
|
|
||||||
/// Configures the certificate verification method for new connections also
|
/// Configures the certificate verification method for new connections also
|
||||||
/// carrying supplied data.
|
/// carrying supplied data.
|
||||||
|
// Note: no option because there is no point to set data without providing
|
||||||
|
// a function handling it
|
||||||
pub fn set_verify_with_data<T>(&mut self, mode: SslVerifyMode,
|
pub fn set_verify_with_data<T>(&mut self, mode: SslVerifyMode,
|
||||||
verify: Option<VerifyCallbackData<T>>,
|
verify: VerifyCallbackData<T>,
|
||||||
data: T) {
|
data: T) {
|
||||||
let data = box data;
|
let data = box data;
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::SSL_CTX_set_ex_data(self.ctx, VERIFY_IDX,
|
ffi::SSL_CTX_set_ex_data(self.ctx, VERIFY_IDX,
|
||||||
mem::transmute(verify));
|
mem::transmute(Some(verify)));
|
||||||
ffi::SSL_CTX_set_ex_data(self.ctx, get_verify_data_idx::<T>(),
|
ffi::SSL_CTX_set_ex_data(self.ctx, get_verify_data_idx::<T>(),
|
||||||
mem::transmute(data));
|
mem::transmute(data));
|
||||||
ffi::SSL_CTX_set_verify(self.ctx, mode as c_int, Some(raw_verify_with_data::<T>));
|
ffi::SSL_CTX_set_verify(self.ctx, mode as c_int, Some(raw_verify_with_data::<T>));
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ fn test_verify_callback_data() {
|
||||||
// Please update if "test/cert.pem" will ever change
|
// Please update if "test/cert.pem" will ever change
|
||||||
let node_hash_str = "6204f6617e1af7495394250655f43600cd483e2dfc2005e92d0fe439d0723c34";
|
let node_hash_str = "6204f6617e1af7495394250655f43600cd483e2dfc2005e92d0fe439d0723c34";
|
||||||
let node_id = hash_str_to_vec(node_hash_str);
|
let node_id = hash_str_to_vec(node_hash_str);
|
||||||
ctx.set_verify_with_data(SslVerifyNone, Some(callback), node_id);
|
ctx.set_verify_with_data(SslVerifyNone, callback, node_id);
|
||||||
ctx.set_verify_depth(1);
|
ctx.set_verify_depth(1);
|
||||||
|
|
||||||
match SslStream::new(&ctx, stream) {
|
match SslStream::new(&ctx, stream) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue