Github: error cloning my private repository

Viewed 198383

I'm trying to clone my GitHub project using the https-URL, but it fails with an error:

$ git clone https://foo@github.com/foo/foo-private.git
Cloning into foo-private...
Password:
error: error setting certificate verify locations:
  CAfile: /bin/curl-ca-bundle.crt
  CApath: none
 while accessing https://foo@github.com/foo/foo-private.git/info/refs

fatal: HTTP request failed

What am I doing wrong?

27 Answers

In my win10 case I have two versions of .gitconfig

  • the first one is in C:\Program Files\Git\etc
  • the second is in C:\Users\<user>

The command

git config --system http.sslcainfo "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt"

indeed makes changes to C:\Program Files\Git\etc, but git somehow uses config in C:\Users\<user>

So with notepad I changed the second one .gitconfig and git finally took right configuration and got working.

I encountered this error after updating to Visual Studio 2019 16.10.2 (from 16.10.0), whereas previously Git was working correctly.

I do not have Git installed separately. (Or, put another way, I only use Git as part of Visual Studio.)

I solved this problem by locating the file "ca-bundle.crt" at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs\ca-bundle.crt", and then copying it to the folder it was indicating it couldn't be found at, "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt".

Do note that I had to create the "\mingw64\ssl\certs" directories, as they did not previously exist.

After copying the file there, Git was able to sync once again immediately without restarting Visual Studio.

In my case, the solution to the problem was to change openssl to schannel:

Before

PS E:\www\XXXXX> git config --global http.sslverify "true"
PS E:\www\XXXXX> git pull origin main --force
fatal: unable to access 'https://gitlab.com/XXXXXXXXX.git/': error setting certificate verify
locations: CAfile: C:\Program Files\Git\mingw64\ssl\certs CApath: C:\Program Files\Git\mingw64\ssl\certs

Solution

PS E:\www\XXXXX> git config --global http.sslbackend schannel

After

PS E:\www\XXXXX> git config --global http.sslverify "true"

PS E:\www\XXXXX> git pull origin main --force

From https://gitlab.com/XXXXXXXXX
  * branch main -> FETCH_HEAD
Already up to date.

It would look like this in C:\Program Files\Git\etc\gitconfig

[http]
sslBackend = schannel
sslcainfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

If anybody else is facing this issue in Git for Windows and do not have curl-ca-bundle.crt anywhere on your system even after reinstalling, this is the process I followed:

  1. Download the latest version of curl here: curl download mirror
  2. Extract and navigate to curl-**.**.*/lib in the command line
  3. Run ./mk-ca-bundle.prl
  4. Copy ca-bundle.crt to your git path and update the config as listed in other answers

Shout out to this gist for helping me get the installation done.

I've solved this problem on a Windows Server 2016 by reinstalling it and by choosing "native Windows Secure Channel library" on the "Choosing HTTPS transport backend" install step.

For MinGit users on Windows 10:

You'll have to make slight adjustments to @mstrap's answer.

git config --system http.sslcainfo "<PATH-TO-MINGIT>\mingw64\ssl\certs\ca-bundle.crt"

On git for Windows you can also reinstall and select the Windows native certificate validation method (OpenSSL is default). This will skip the OpenSSL verification and instead use the Windows native one, which doesn't require maintaining a separate tool (OpenSSL) and certificates.

Worked perfectly for me :)

The solution that work for me in windows 64bits is the following

git config --system http.sslverify false

Related