173

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?

Mot
  • 28,248
  • 23
  • 84
  • 121

27 Answers27

315

I have seen this on Windows, with msysgit 1.7.2.3. You have to fix the path to bin/curl-ca-bundle.crt. I had to specify the absolute path, using back-slashes:

git config --system http.sslcainfo "C:\Program Files (x86)\git\bin\curl-ca-bundle.crt"

This will result in changes to [git-install-dir]/etc/gitconfig file, which may be edited directly, too.

(Original solutions found at http://github.com/blog/642-smart-http-support)

mstrap
  • 16,808
  • 10
  • 56
  • 86
  • 1
    In my case I needed to use the directory delimiter for windows, i mean, i have to use the "\" (windows) instead of "/" (unix) for separating directories in the path. – Victor Nov 10 '15 at 21:55
  • As original post writing below works for me Try it out on a public repository: $ git clone http://github.com/schacon/grack.git For private repos, or to have push access on your repository, you can clone this way: $ git clone https://username@github.com/username/project.git Thanks :) – J4cK Apr 07 '16 at 14:16
  • Make sure that you look into Program Files and Program Files (x86) ! Bloody Windows – Mo Zaatar Jun 20 '17 at 12:54
  • 17
    For future references the path seems to have changed for me to "C:\Program Files (x86)\Git\mingw32\ssl\certs\ca-bundle.crt" – Ben Sep 24 '17 at 16:46
  • Not working for me ...please suggest something..Cloning the MEAN repo....... Error: Command failed: git clone --branch v0.4.2 https://github.com/meanjs/mean. git mean Cloning into 'mean'... fatal: unable to access 'https://github.com/meanjs/mean.git/': error setting cer tificate verify locations: CAfile: /mingw64/ssl/certs/ca-bundle.crt CApath: none – prabhat mishra Feb 15 '18 at 11:21
  • 3
    The path on my 64 bit machine is "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt" – Kamaraju Kusumanchi Mar 16 '18 at 23:10
  • I just want to point out that setting `http.sslverify false` is not recommended and the answwer should be updated to reflect this. – Aaron C May 04 '18 at 14:56
  • The answer says ".. -- not really recommended -- ..." already. – mstrap May 06 '18 at 09:00
  • 6
    On my 64 bit machine, `git config --global http.sslcainfo "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt"` worked, can't say why global while system failed. – rkouye May 14 '18 at 14:05
  • [Why does curl fail?](https://github.com/Linuxbrew/brew/wiki/FAQ#why-does-curl-fail), fixed mine! – Itachi Jan 12 '19 at 12:04
  • I have added `git config --system http.sslverify false` and it STILL gives me the `error setting certificate verify locations` error. Nothing requiring internet works from git bash but Windows cmd has no problems. – Xeverous Mar 13 '20 at 09:57
94

I solved the problem installing Git from: https://git-for-windows.github.io/

Locate the cert file path:

D:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt

Configure the Git path:

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

Try again

John Smith
  • 7,243
  • 6
  • 49
  • 61
rogertoday
  • 941
  • 6
  • 2
  • 14
    I got `error: could not lock config file C:\Program Files\Git\mingw64/etc/gitconfig: Permission denied`. Ran `"C:\Program Files\Git\git-bash.exe"` as administrator and tried again and it worked. Thanks! – AXO Dec 26 '15 at 02:49
  • Better Explaination – Kasim Rangwala Apr 02 '17 at 08:57
  • 2
    I've just installed Git for Windows 2.13.2 and ran into this problem trying to push to the remote. I found the cert file was in a similar location: `C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt` – Simon Elms Aug 07 '17 at 13:40
  • 1
    this worked for me, I only installed the Git using the link u shared and that solved it for me, Thanks – Sunny Okoro Awa Oct 16 '17 at 09:36
  • I had installed GIT on a specified directory during installation time, hence I had to specify the correct MINGW64 path as per that installation – gargkshitiz Aug 22 '18 at 08:19
26

If you use MSYS2...

Just install the certificate packages with the following commands:

32 bits

pacman -S mingw-w64-i686-ca-certificates ca-certificates

64 bits

pacman -S mingw-w64-x86_64-ca-certificates ca-certificates
CoolOppo
  • 503
  • 9
  • 17
12

If you were using Cygwin, you might install the ca-certificates package with apt-cyg:

wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /usr/local/bin
apt-cyg install ca-certificates

How do I install a cygwin package from the command line?

Community
  • 1
  • 1
Jiangwei Yu
  • 609
  • 7
  • 7
12
git config --global http.sslverify "false" 

Will solve the problem. After that a Pop-up window appears to enter your username and password

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Abubakr Elghazawy
  • 977
  • 14
  • 21
6

SOLVED: I got this error when I installed an update to the Git windows installer. What happened is that I did not install it with administrator rights, so Git was installed in "C:\Users\my_name\AppData\Local\Programs" instead of "C:\program Files". re-installing Git as administrator allowed to put it in C:\program Files and everything went fine again !

Louis BAYLE
  • 81
  • 1
  • 3
  • For what it's worth, uninstalling and reinstalling GitHub Desktop fixed this for me too, despite it still using the AppData folder. – Ben Collier Dec 24 '15 at 18:58
5

This worked for me (I'm using Manjaro linux). I run the cmd to view ca-certificates:

$ curl-config --ca
**/etc/ssl/certs/ca-certificates.crt**

But actually i found the certificates at the path:

**/etc/ca-certificates/extracted/ca-bundle.trust.crt**

Then add the config into ~/.gitconfig (if not existing, create it):

**vim ~/.gitconfig**
[http]
    sslVerify = true
    sslCAinfo = /etc/ca-certificates/extracted/ca-bundle.trust.crt

[user]
    email = <email of github account>
    name = <username of github account>

It works!

.rbenv]$ git pull

remote: Counting objects: 70, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 70 (delta 39), reused 12 (delta 12), pack-reused 6
Unpacking objects: 100% (70/70), done.
From https://github.com/sstephenson/rbenv
   c43928a..efb187f  master     -> origin/master
 + 37ec781...7e57b52 user-gems  -> origin/user-gems  (forced update)
Updating c43928a..efb187f
Fast-forward
 libexec/rbenv-init         |  4 ++--
 libexec/rbenv-version-file |  1 +
 test/init.bats             |  2 +-
 test/test_helper.bash      | 25 +++++++++++++++----------
 4 files changed, 19 insertions(+), 13 deletions(-)
chappjc
  • 30,359
  • 6
  • 75
  • 132
Duy Nguyen
  • 53
  • 1
  • 3
4

git config --system http.sslcainfo /bin/curl-ca-bundle.crt

This works. You don't have to give full path.

KannarKK
  • 1,593
  • 20
  • 35
3

I faced this while git pull. For mine edited the global git config file that fixed problem.

Goto your home folder and open .gitconfig file. Usually C:\Users\.gitconfig

If the file is not there create it

[http]
sslcainfo = E:\systools\git-1.8.5.2\bin\curl-ca-bundle.crt

There you have to given your own git installation path. I have used portable version of git here.

Then git clone / pull it will work.

arulraj.net
  • 4,579
  • 3
  • 36
  • 37
3

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.

d0wn
  • 121
  • 4
  • Thanks. I had same issue and found what you said. Setting cert with `git config --global` was not setting the path correctly in `C:\Users\` so I had to update it manually and issue was fixed. – Mital Pritmani Aug 21 '20 at 04:49
2

If you are using the Git command shell that installs with the GitHub for Windows app then this and various other problems can show after an update. Just start the Git Hub windows app and shut it down again. The shell will then work OK again. The problem is that the update does not complete until the windows application is run. Just using the shell on its does not trigger the update to complete.

Paul D
  • 601
  • 7
  • 13
2

I've seen this on my Github for Windows.

I recommend uninstalling Github for Windows and installing it again.

Before this, I tried several ways with no success, but this solution worked for me!

Alisa
  • 2,892
  • 3
  • 31
  • 44
2

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
Lon
  • 21
  • 2
1

On Windows using msysgit I had this error and the cause was my additions of our corporate proxy certificates.

If you edit your curl-ca-bundle.crt you have to get sure about your lineendings. In case of the curl-ca-bundle you have to use Linux-Style lineendings.

> git ls-remote --tags --heads https://github.com/oblador/angular-scroll.git
fatal: unable to access 'https://github.com/oblador/angular-scroll.git/': error setting certificate verify locations:
  CAfile: C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt
  CApath: none

You can use notepad++ to convert the lineendings to Linux (linefeed).

Thomas
  • 2,127
  • 1
  • 32
  • 45
1

On a side note, this issue can happen in Windows if the user who is trying to use git is different than the user who installed it. The error may indicate that git cannot access the certificate files. Installing git as the administrator and using @rogertoday's answer resolved my issue.

Maghoumi
  • 3,295
  • 3
  • 33
  • 49
1

I found a good solution for adding/updating the CA certificates on RHEL/CentOS 6 which is the root cause reported issue.

Since they become outdated distros, the cacert authorities in that system has not been updated until executing the command sudo yum update.

Didn't realize the issue until the GIT_CURL_VERBOSE mode shows the cacert path issue.

S.K. Venkat
  • 1,749
  • 2
  • 23
  • 35
1

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.

Justin Shidell
  • 588
  • 1
  • 5
  • 16
0

On Linux, I had this error and fixed it by running sudo update-ca-certificates.

user5002062
  • 541
  • 3
  • 8
  • You should explain what this command does and why this helps. Posting raw commands without explanation is not a good idea, specially if you need root access. – Peanut Jun 12 '15 at 06:43
0

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.

Community
  • 1
  • 1
tordal
  • 644
  • 5
  • 17
0

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.

Thibault
  • 842
  • 2
  • 8
  • 16
0

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"
Jarmos
  • 336
  • 1
  • 8
  • 22
-1

For me what solved the problem was when on my windows 10 box, I tried uninstalling git and resintalling, using Windows Cmd as default not Git Bash

Open CMD and run the following

//Once installed try to resintall the bin folder 
git config --system http.sslcainfo \bin/curl-ca-bundle.crt

//disable ssl verification
git config --global http.sslverify "false"

//Then try to clone repo again
git clone git@github.com:account/someproject.git
krock
  • 28,904
  • 13
  • 79
  • 85
-1

I received this error after moving git across hard drives. Deleting and reinstalling in the new location fixed things

gamesguru
  • 92
  • 1
  • 3
  • 6
-1

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 :)

reijin
  • 133
  • 10
-1

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

git config --system http.sslverify false

Jorge Santos Neill
  • 1,635
  • 13
  • 6
-2

I was able to solve this issue with the following command.

git config --system http.sslverify false

  • This answer would be better if it discussed the security ramifications of this setting and provided other ways of solving the problem as well. Though, the current accepted answer does this and more... – chwarr Apr 19 '17 at 21:40
-2

The following command

git clone git://github.com/username/projectname.git

worked for my needs, but I assume you want more than read-only access, right?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338