diff --git a/rustls-libssl/build.rs b/rustls-libssl/build.rs index fdf5a6b..4d0051d 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 1f4eccf..b7236c6 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 @@ -226,6 +226,24 @@ impl Drop for Bio { } } +static NAME: &CStr = c"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 b7a103a..2981f71 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, str_from_cstring, to_arc_mut_ptr, try_clone_arc, try_from, try_mut_slice_int, @@ -69,6 +69,12 @@ entry! { } } +entry! { + pub fn _BIO_f_ssl() -> *const BIO_METHOD { + &crate::bio::SSL_BIO_METHOD + } +} + type SSL_METHOD = crate::SslMethod; entry! {