rust-lang / rust-lang/git2-rs

`RepoBuilder` HTTPS clone of bitbucket.org --> Certificate Error

Open
#782 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
450
Avg merge
11m
Merged PRs (30d)
1

Description

Using git2 version 0.3.24. I'm trying to clone using a RepoBuilder. Relevant code snippet:

let mut builder = git2::build::RepoBuilder::new();
if let Some(callbacks) = params.make_callbacks() {
    let mut options = git2::FetchOptions::new();
    options.remote_callbacks(callbacks);
    builder.fetch_options(options);
}

let repo = builder.clone(params.clone_url.as_ref(), path)?;
Ok(repo)

This is generic clone code and works against a local Gogs host (using self signed certs - so cert validation is turned off in callbacks). It works for Bitbucket if I disable cert validation, so I know the callbacks are being attached as it also attaches authentication.

Under WSL2 (Ubuntu 20.04) I get this error when I attempt to clone a private repo from bitbucket.org:

Error { code: -1, klass: 34, message: "user rejected certificate for bitbucket.org" }

Under Windows (same host) I get this error:

Error { code: -1, klass: 34, message: "user cancelled certificate check" }

In my RemoteCallbacks if I allow bad certs it works fine, but I really want to validate this cert. Other programs such as git and curl in both WSL2 and Windows are able to use bitbucket.org just fine, so it doesn't seem to be an issue with the root certs in the OS. I've tried both vendored-libgit2 and vendored-openssl to no avail. I'm not quite sure where to look and if this is a bug or a configuration goof on my part. Any guidance appreciated, thx.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the RepoBuilder::clone call and the RemoteCallbacks certificate-validation behavior shown in the issue. Compare how git2/libgit2 handles the Bitbucket certificate on WSL2 Ubuntu 20.04 and Windows, including the vendored-libgit2 and vendored-openssl configurations. Done means private Bitbucket cloning validates the certificate without allowing bad certificates.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.