3

I tried cloning a few repositories, but always get the same error. Where can I find some more information about this error (an error log file or something similar) or maybe someone knows what can be wrong?

# git clone http://github.com/creationix/nvm.git .nvm
Initialized empty Git repository in /home/marcin/.nvm/.git/
error:  while accessing http://github.com/creationix/nvm.git/info/refs

fatal: HTTP request failed

or

# git clone https://gitlab.com/jmis/exilecraft.git
Initialized empty Git repository in /home/marcin/exilecraft/.git/
error:  while accessing https://gitlab.com/jmis/exilecraft.git/info/refs

fatal: HTTP request failed

I'm using CentOS 6.8 and Git 1.7.1

---------- EDIT
after upgrade Git to 2.12.0 I have error message:

# git clone https://github.com/creationix/nvm.git .nvm
Cloning into '.nvm'...
fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)  
MastaBot
  • 273
  • 2
  • 4
  • 16
  • As a data point, using git 1.7.1 under CentOS 6.8, I can clone the second URL without a problem, and I can clone the first URL if I change `http://` to `https://`. The problem goes away completely if I use a newer version of `git`. – larsks Feb 24 '17 at 20:41
  • I try update git to latest release but `git clone` doesn't work for me :/ – MastaBot Feb 24 '17 at 21:23

3 Answers3

5

That error is clearly described in HTTPS cloning errors

Depending on the exact error message, trying to clone with your username in the url can help:

git clone https://<username>@github.com/<username>/<repo.git>

But ideally, you should recompile and install a more recent version of Git.

With Git version 2.12.0, the error message is:

fatal: unable to access 'https://github.com/creationix/nvm.git/': 
Problem with the SSL CA cert 

Make sure you have installed the certificates:

sudo yum reinstall openssl ca-certificates -y

The manual version of this fix is:

mkdir -p /etc/pki/tls/certs
curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/ca-bundle.crt
git config --global http.sslcainfo /etc/pki/tls/ca-bundle.crt
git config -l 

Another approach is described here:

mkdir /usr/src/ca-certificates && cd /usr/src/ca-certificates
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm
rpm2cpio ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm | cpio -idmv
cp -pi ./etc/pki/tls/certs/ca-bundle.* /etc/pki/tls/certs/

Note: edtech adds in the comments:

Upgrading the nss package ( yum update nss ) has solved the same problem for me.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • using my github username I get `fatal: HTTP request failed`, now I try to recompile Git – MastaBot Feb 24 '17 at 21:29
  • @MastaBot you mention in your top comment having updated git to the latest relase though. What error message did you get? – VonC Feb 24 '17 at 21:31
  • now I have Git version 2.12.0 and still have error, now error message is `fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)` – MastaBot Feb 24 '17 at 21:45
  • @MastaBot maybe you don't have those certificates, see my edited answer – VonC Feb 24 '17 at 21:50
  • Is `yum reinstall ca-certificates` safe for my working apache with SSL? – MastaBot Feb 24 '17 at 21:53
  • @MastaBot Then try the manual version (see edited answer): you can curl those certificates in any path you want (in case /etc/pki/tls/ca-bundle.crt already exist) – VonC Feb 24 '17 at 21:54
  • heh :/ git error `error: could not lock config file /usr/local/git/etc/gitconfig: No such file or directory` when try `git config --system http.sslcainfo /etc/pki/tls/ca-bundle.crt` now I try to "First-Time Git Setup" – MastaBot Feb 24 '17 at 22:01
  • @MastaBot replace `--system` by `--global` in the `git config` command. I have edited my answer – VonC Feb 24 '17 at 22:10
  • still `fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)` for sure I `rm /etc/pki/tls/ca-bundle.crt` and curl it again – MastaBot Feb 24 '17 at 22:15
  • @MastaBot OK, I have added another possible solution – VonC Feb 24 '17 at 22:28
  • still same error `fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)` :( – MastaBot Feb 24 '17 at 22:40
  • @MastaBot did you check the rights associated with `/etc/pki/tls/ca-bundle.crt`? Can your current user access/read that file? – VonC Feb 24 '17 at 22:47
  • sure, all things above I do as root, then I can modify/remove etc ca-bundle.crt file – MastaBot Feb 24 '17 at 22:51
  • @MastaBot But your git command is not done as root, so the question is: can you access it from your current user. – VonC Feb 24 '17 at 23:26
  • Ok, I see where is problem :/ when I open `/etc/pki/tls/ca-bundle.crt` with my editor then I see inside info `Resource is gone` you give me outdated url the correct one is `https://curl.haxx.se/ca/cacert.pem` any way you help me a lot, thanks! Pls edit your answer to correct this link. – MastaBot Feb 24 '17 at 23:35
  • @MastaBot Great. I have updated the answer with the right url. – VonC Feb 24 '17 at 23:37
  • Upgrading the nss package ( `yum update nss` ) has solved the same problem for me – edtech Apr 05 '18 at 21:07
  • @edtech Thank you. I have included your comment in the answer for more visibility. – VonC Apr 06 '18 at 07:28
2

There can be a variety of reasons (proxy, firewall, company policy and more).
As far as i know github has removed the support for the http and now only support https

Change the protocol to ssh and it will work without any problems.

There is a very detailed document on how to do it.
https://help.github.com/articles/connecting-to-github-with-ssh/

To summarize it:

  • Generate ssh key locally
    open git-bash/terminal and generate the key ssh-keygen
  • Copy the key cat ~/.ssh/id_rsa.pub
  • open git hub ans paste the key under your profile settings
  • Clone with the ssh url instead of the http/https.

Login to your github account

  • In the upper-right corner of any page, click your profile photo, then click Settings.

enter image description here

  • In the user settings sidebar, click SSH and GPG keys

enter image description here.

  • Click New SSH key or Add SSH key.

enter image description here

  • Paste your key into the Key field.

enter image description here

  • Click Add SSH key.

enter image description here

  • If prompted, confirm your GitHub password.

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • after adding SSH Key on github I still get same error – MastaBot Feb 24 '17 at 21:21
  • Are you contributor to the project? if its a private repo you must be contributor to clone it. – CodeWizard Feb 24 '17 at 21:23
  • I only want update my nvm (node version manager) and all (or many instruction how to do it start with `git clone http://github.com/creationix/nvm.git` – MastaBot Feb 24 '17 at 21:26
  • You can also install it like this: `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash` – CodeWizard Feb 24 '17 at 21:43
1

If you are getting "SSL connect error" try to update nss and curl.

For example on CentOS:

yum update -y nss curl

Valéry
  • 344
  • 2
  • 6