Skip to content

Commit fce9ed4

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

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/easy/handler.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,20 @@ 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 {
687+
PROBE.as_ref().unwrap()
688+
};
689+
677690
if let Some(ref path) = probe.cert_file {
678691
let _ = self.cainfo(path);
679692
}

0 commit comments

Comments
 (0)