Skip to content

Commit

Permalink
Probe for OpenSSL certificates only once (#363)
Browse files Browse the repository at this point in the history
Fixes #362.
  • Loading branch information
sagebind authored Oct 30, 2020
1 parent e56c789 commit 65cb1c2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/easy/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,18 @@ impl<H: Handler> Easy2<H> {

#[cfg(need_openssl_probe)]
fn ssl_configure(&mut self) {
let probe = ::openssl_probe::probe();
use std::sync::Once;

static mut PROBE: Option<::openssl_probe::ProbeResult> = None;
static INIT: Once = Once::new();

// Probe for certificate stores the first time an easy handle is created,
// and re-use the results for subsequent handles.
INIT.call_once(|| unsafe {
PROBE = Some(::openssl_probe::probe());
});
let probe = unsafe { PROBE.as_ref().unwrap() };

if let Some(ref path) = probe.cert_file {
let _ = self.cainfo(path);
}
Expand Down

0 comments on commit 65cb1c2

Please sign in to comment.