Skip to content

Commit

Permalink
Don't panic setting CAINFO/CAPATH options
Browse files Browse the repository at this point in the history
This isn't always built into curl so if our automatically setting it fails we
should just continue on.
  • Loading branch information
alexcrichton committed Sep 8, 2015
1 parent 56e6366 commit b4cb511
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/http/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use std::path::Path;

use url::Url;

use ffi;
use ffi::opt;
use ffi::easy::Easy;
use ffi::err;
use ffi::opt;
use ffi;
use http::Response;
use http::body::{Body,ToBody};
use {ProgressCb,ErrCode};
Expand All @@ -26,15 +27,23 @@ impl Handle {
.connect_timeout(DEFAULT_TIMEOUT_MS));

#[cfg(unix)]
fn configure(handle: Handle) -> Handle {
fn configure(mut handle: Handle) -> Handle {
let probe = ::openssl::probe::probe();
let handle = match probe.cert_file {
Some(ref path) => handle.ssl_ca_info(path),
None => handle,
};
match probe.cert_dir {
Some(ref path) => handle.ssl_ca_path(path),
None => handle,
if let Some(ref path) = probe.cert_file {
set_path(&mut handle, opt::CAINFO, path);
}
if let Some(ref path) = probe.cert_dir {
set_path(&mut handle, opt::CAPATH, path);
}
return handle;

fn set_path(handle: &mut Handle, opt: opt::Opt, path: &Path) {
if let Err(e) = handle.easy.setopt(opt, path) {
if let err::NOT_BUILT_IN = e.code() {
return
}
panic!("failed to set {:?}: {}", opt, e)
}
}
}

Expand Down

0 comments on commit b4cb511

Please sign in to comment.