Make shims for SSL_CTX_ctrl and SSL_CTX_callback_ctrl macro wrappers
This commit is contained in:
parent
e486944320
commit
7835ea1c90
|
|
@ -4,7 +4,7 @@
|
||||||
extern crate openssl_sys;
|
extern crate openssl_sys;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use libc::{c_int, c_uint, c_long, c_char};
|
use libc::{c_int, c_uint, c_long, c_char, c_void};
|
||||||
use openssl_sys::{HMAC_CTX, EVP_MD, ENGINE, SSL_CTX, BIO, X509, stack_st_X509_EXTENSION, SSL, DH};
|
use openssl_sys::{HMAC_CTX, EVP_MD, ENGINE, SSL_CTX, BIO, X509, stack_st_X509_EXTENSION, SSL, DH};
|
||||||
|
|
||||||
macro_rules! import_options {
|
macro_rules! import_options {
|
||||||
|
|
@ -65,4 +65,8 @@ extern {
|
||||||
pub fn SSL_CTX_set_tmp_dh(s: *mut SSL, dh: *const DH) -> c_long;
|
pub fn SSL_CTX_set_tmp_dh(s: *mut SSL, dh: *const DH) -> c_long;
|
||||||
#[link_name = "X509_get_extensions_shim"]
|
#[link_name = "X509_get_extensions_shim"]
|
||||||
pub fn X509_get_extensions(x: *mut X509) -> *mut stack_st_X509_EXTENSION;
|
pub fn X509_get_extensions(x: *mut X509) -> *mut stack_st_X509_EXTENSION;
|
||||||
|
#[link_name = "SSL_CTX_set_tlsext_servername_callback_shim"]
|
||||||
|
pub fn SSL_CTX_set_tlsext_servername_callback(ssl: *mut SSL_CTX, callback: Option<extern fn()>);
|
||||||
|
#[link_name = "SSL_CTX_set_tlsext_servername_arg_shim"]
|
||||||
|
pub fn SSL_CTX_set_tlsext_servername_arg(ssl: *mut SSL_CTX, arg: *const c_void);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,14 @@ long SSL_CTX_set_tmp_dh_shim(SSL_CTX *ctx, DH *dh) {
|
||||||
return SSL_CTX_set_tmp_dh(ctx, dh);
|
return SSL_CTX_set_tmp_dh(ctx, dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long SSL_CTX_set_tlsext_servername_callback_shim(SSL_CTX *ctx, int (*callback)(SSL_CTX *, int *, void*)) {
|
||||||
|
return SSL_CTX_set_tlsext_servername_callback(ctx, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
long SSL_CTX_set_tlsext_servername_arg_shim(SSL_CTX *ctx, void* arg) {
|
||||||
|
return SSL_CTX_set_tlsext_servername_arg(ctx, arg);
|
||||||
|
}
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||||
int SSL_CTX_set_ecdh_auto_shim(SSL_CTX *ctx, int onoff) {
|
int SSL_CTX_set_ecdh_auto_shim(SSL_CTX *ctx, int onoff) {
|
||||||
return SSL_CTX_set_ecdh_auto(ctx, onoff);
|
return SSL_CTX_set_ecdh_auto(ctx, onoff);
|
||||||
|
|
|
||||||
|
|
@ -571,9 +571,6 @@ extern "C" {
|
||||||
|
|
||||||
pub fn SSL_CTX_set_cipher_list(ssl: *mut SSL_CTX, s: *const c_char) -> c_int;
|
pub fn SSL_CTX_set_cipher_list(ssl: *mut SSL_CTX, s: *const c_char) -> c_int;
|
||||||
|
|
||||||
pub fn SSL_CTX_ctrl(ssl: *mut SSL_CTX, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
|
|
||||||
pub fn SSL_CTX_callback_ctrl(ssl: *mut SSL_CTX, cmd: c_int, callback: Option<extern fn()>) -> c_long;
|
|
||||||
|
|
||||||
#[cfg(feature = "npn")]
|
#[cfg(feature = "npn")]
|
||||||
pub fn SSL_CTX_set_next_protos_advertised_cb(ssl: *mut SSL_CTX,
|
pub fn SSL_CTX_set_next_protos_advertised_cb(ssl: *mut SSL_CTX,
|
||||||
cb: extern "C" fn(ssl: *mut SSL,
|
cb: extern "C" fn(ssl: *mut SSL,
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@ impl SslContext {
|
||||||
ffi::SSL_CTX_set_ex_data(self.ctx, SNI_IDX,
|
ffi::SSL_CTX_set_ex_data(self.ctx, SNI_IDX,
|
||||||
mem::transmute(callback));
|
mem::transmute(callback));
|
||||||
let f: extern fn() = mem::transmute(raw_sni);
|
let f: extern fn() = mem::transmute(raw_sni);
|
||||||
ffi::SSL_CTX_callback_ctrl(self.ctx, ffi::SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, Some(f));
|
ffi_extras::SSL_CTX_set_tlsext_servername_callback(self.ctx, Some(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -566,9 +566,9 @@ impl SslContext {
|
||||||
ffi::SSL_CTX_set_ex_data(self.ctx, SNI_IDX,
|
ffi::SSL_CTX_set_ex_data(self.ctx, SNI_IDX,
|
||||||
mem::transmute(Some(callback)));
|
mem::transmute(Some(callback)));
|
||||||
|
|
||||||
ffi::SSL_CTX_ctrl(self.ctx, ffi::SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, mem::transmute(data));
|
ffi_extras::SSL_CTX_set_tlsext_servername_arg(self.ctx, mem::transmute(data));
|
||||||
let f: extern fn() = mem::transmute(raw_sni_with_data::<T>);
|
let f: extern fn() = mem::transmute(raw_sni_with_data::<T>);
|
||||||
ffi::SSL_CTX_callback_ctrl(self.ctx, ffi::SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, Some(f));
|
ffi_extras::SSL_CTX_set_tlsext_servername_callback(self.ctx, Some(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue