Skip to content

Commit afbc72c

Browse files
committed
Probe for OpenSSL certificates only once
Fixes #362.
1 parent e56c789 commit afbc72c

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+
let probe = INIT.call_once(|| unsafe {
684+
PROBE = Some(::openssl_probe::probe());
685+
PROBE.as_ref().unwrap()
686+
});
687+
677688
if let Some(ref path) = probe.cert_file {
678689
let _ = self.cainfo(path);
679690
}

0 commit comments

Comments
 (0)