Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probe for OpenSSL certificates only once #363

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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