Friday, July 22, 2011

Cloning a GitHub GIT Repository on Ubuntu 8.04 LTS

At work, we're still running Ubuntu 8.04 LTS on most PCs with Linux. Most of the time the age of the operating system isn't a problem - but sometimes it can be a pain. Case in point: cloning a GIT repository hosted on GitHub. This used to work just fine, until they switched to HTTPS:
$ git clone https://github.com/user/repo.git
Initialized empty Git repository in /current/directory/repo/.git/
Cannot get remote repository information.
Perhaps git-update-server-info needs to be run there?
When this first happened, I shrugged it off as a problem with the remote end, and just downloaded a source tarball from https://github.com/user/repo/tarball/master. But a few weeks later I got this error again with a different repository, and got annoyed. I tried the same command at home (Debian/testing, GIT version 1.7.5.4):
$ git clone https://github.com/user/repo.git
Cloning into repo...
remote: Counting objects: 81, done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 81 (delta 34), reused 55 (delta 8)
Unpacking objects: 100% (81/81), done.
So, this is a problem with either GIT at work, or the Net connection. I downloaded the GIT source tarball and installed it locally in my account (at ~/local):
wget -c http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2
tar xvjf git-1.7.6.tar.bz2
cd git-1.7.6
ls
./configure --prefix=$HOME/local
make
make install
and since we're using tcsh at work (don't ask), I also had to type rehash in order to convince the shell to use the newly installed GIT.

Here's what I got this time:
$ git clone https://github.com/user/repo.git
Cloning into repo...
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/user/repo.git/info/refs

fatal: HTTP request failed
... which is useful: Google directed me to a question on Stack-Overflow. Most of the answers there deal with installing CA certificates, but the following trick works nicely with git version 1.5.4.3 on Ubuntu 8.04.4 LTS:
$ env GIT_SSL_NO_VERIFY=true git clone https://github.com/user/repo.git
Cloning into repo...
remote: Counting objects: 81, done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 81 (delta 34), reused 55 (delta 8)
Unpacking objects: 100% (81/81), done.
(no need for env in bash).

And while we're at it, here's another trick that might be handy in the future:
$ env GIT_CURL_VERBOSE=1 git clone https://github.com/user/repo.git
Cloning into repo...
* Couldn't find host github.com in the .netrc file, using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Connection #0 to host github.com left intact
* Couldn't find host github.com in the .netrc file, using defaults
* Connection #0 seems to be dead!
* Closing connection #0
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Expire cleared
* Connection #0 to host github.com left intact
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/user/repo.git/info/refs

fatal: HTTP request failed

2 comments:

  1. did you find any solution to this issue. I am starting a basic intranet at work and am about to buy ssl certificate for the external access but we are having this issue when we try to connect to the server via https. If you have any idea want is going on or how to sort it out i would be really tankful.

    ReplyDelete
  2. I don't know... I've never setup a git server over https, but it looks like you're trying to verify against a self-signed ssl cert, so I guess you have to install it on the client machine, and maybe tell git to use it (see this link for example).

    ReplyDelete