diff --git a/rustls-libssl/build.rs b/rustls-libssl/build.rs index f467ea0..569aa82 100644 --- a/rustls-libssl/build.rs +++ b/rustls-libssl/build.rs @@ -42,6 +42,7 @@ fn write_version_file() -> String { } const ENTRYPOINTS: &[&str] = &[ + "BIO_f_ssl", "OPENSSL_init_ssl", "SSL_alert_desc_string", "SSL_alert_desc_string_long", diff --git a/rustls-libssl/src/bio.rs b/rustls-libssl/src/bio.rs index 14f6f1a..08b44df 100644 --- a/rustls-libssl/src/bio.rs +++ b/rustls-libssl/src/bio.rs @@ -1,4 +1,4 @@ -use core::ffi::{c_char, c_int, c_long, c_void}; +use core::ffi::{c_char, c_int, c_long, c_void, CStr}; use std::io; // nb. cannot use any BIO types from openssl_sys: it doesn't @@ -223,6 +223,24 @@ impl Drop for Bio { } } +static NAME: &CStr = crate::constants::constant_cstr!("ssl"); +const BIO_TYPE_SSL: i32 = 0x0200 | 7; + +pub static SSL_BIO_METHOD: bio_method_st = bio_method_st { + type_: BIO_TYPE_SSL, + name: NAME.as_ptr(), + bwrite: None, + bwrite_old: None, + bread: None, + bread_old: None, + bputs: None, + bgets: None, + ctrl: None, + create: None, + destroy: None, + callback_ctrl: None, +}; + // This is a public interface between libcrypto and libssl, but is // defined in `internal/bio.h`. Hmm. #[repr(C)] diff --git a/rustls-libssl/src/entry.rs b/rustls-libssl/src/entry.rs index eb9121f..b8f6c70 100644 --- a/rustls-libssl/src/entry.rs +++ b/rustls-libssl/src/entry.rs @@ -12,7 +12,7 @@ use openssl_sys::{ stack_st_X509, OPENSSL_malloc, X509, X509_STORE, X509_STORE_CTX, X509_V_ERR_UNSPECIFIED, }; -use crate::bio::{Bio, BIO}; +use crate::bio::{Bio, BIO, BIO_METHOD}; use crate::error::{ffi_panic_boundary, Error, MysteriouslyOppositeReturnValue}; use crate::ffi::{ free_arc, to_arc_mut_ptr, try_clone_arc, try_mut_slice_int, try_ref_from_ptr, try_slice, @@ -68,6 +68,12 @@ entry! { } } +entry! { + pub fn _BIO_f_ssl() -> *const BIO_METHOD { + &crate::bio::SSL_BIO_METHOD + } +} + type SSL_METHOD = crate::SslMethod; entry! {