Skip to content

Commit

Permalink
Probe for OpenSSL certificates only once
Browse files Browse the repository at this point in the history
Fixes #362.
  • Loading branch information
sagebind committed Oct 29, 2020
1 parent e56c789 commit fce9ed4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/easy/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,20 @@ 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 fce9ed4

Please sign in to comment.