Skip to content

Commit ed86267

Browse files
committed
Make openssl not cleanup at exit, which can lead to race conditions on openssl >= 1.1.1.
Fixes #1293.
1 parent 5cf2c2d commit ed86267

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

openssl-sys/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ pub fn init() {
101101
// explicitly initialize to work around https://github.com/openssl/openssl/issues/3505
102102
static INIT: Once = Once::new();
103103

104+
#[cfg(all(ossl110, not(ossl111)))]
105+
let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS;
106+
#[cfg(ossl111)]
107+
let init_options = OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_NO_ATEXIT;
108+
104109
INIT.call_once(|| unsafe {
105-
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, ptr::null_mut());
110+
OPENSSL_init_ssl(init_options, ptr::null_mut());
106111
})
107112
}
108113

openssl-sys/src/ssl.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,8 @@ cfg_if! {
13981398

13991399
#[cfg(ossl110)]
14001400
pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000;
1401+
#[cfg(ossl111)]
1402+
pub const OPENSSL_INIT_NO_ATEXIT: u64 = 0x00080000;
14011403

14021404
extern "C" {
14031405
#[cfg(ossl110)]

0 commit comments

Comments
 (0)