Skip to content

Commit 65cb1c2

Browse files
authored
Probe for OpenSSL certificates only once (#363)
Fixes #362.
1 parent e56c789 commit 65cb1c2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/easy/handler.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,18 @@ impl<H: Handler> Easy2<H> {
673673

674674
#[cfg(need_openssl_probe)]
675675
fn ssl_configure(&mut self) {
676-
let probe = ::openssl_probe::probe();
676+
use std::sync::Once;
677+
678+
static mut PROBE: Option<::openssl_probe::ProbeResult> = None;
679+
static INIT: Once = Once::new();
680+
681+
// Probe for certificate stores the first time an easy handle is created,
682+
// and re-use the results for subsequent handles.
683+
INIT.call_once(|| unsafe {
684+
PROBE = Some(::openssl_probe::probe());
685+
});
686+
let probe = unsafe { PROBE.as_ref().unwrap() };
687+
677688
if let Some(ref path) = probe.cert_file {
678689
let _ = self.cainfo(path);
679690
}

0 commit comments

Comments
 (0)