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

Respect git conventions when validating certs #2408

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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: 11 additions & 4 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::env;
use std::fmt;
use std::path::{Path, PathBuf};
use std::fs::{self, File};
use std::path::{Path, PathBuf};

use rustc_serialize::{Encodable, Encoder};
use url::Url;
Expand Down Expand Up @@ -422,11 +423,17 @@ fn with_authentication<T, F>(url: &str, cfg: &git2::Config, mut f: F)

pub fn fetch(repo: &git2::Repository, url: &str,
refspec: &str) -> CargoResult<()> {
// Create a local anonymous remote in the repository to fetch the url

with_authentication(url, &try!(repo.config()), |f| {
let config = try!(repo.config());
let noverify = env::var("GIT_SSL_NO_VERIFY").is_ok() ||
config.get_bool("http.sslVerify").ok() == Some(false);
with_authentication(url, &config, |f| {
let mut cb = git2::RemoteCallbacks::new();
cb.credentials(f);
if noverify {
cb.certificate_check(|_, _| true);
}

// Create a local anonymous remote in the repository to fetch the url
let mut remote = try!(repo.remote_anonymous(&url));
let mut opts = git2::FetchOptions::new();
opts.remote_callbacks(cb)
Expand Down