Wednesday, August 22, 2012

Push back to Gitblit over https, without a valid certificate

Now I have a Gitblit server running, waiting to be connected. The good thing about Gitblit is, you do not even need Git on the server, its package contains a Java implementation of Git. In the long run, you still need it, since the document says git-gc is not properly implemented.

If you already have a Git repository on your local PC, and you want to push it to Gitblit, it's quite simple:

1. Using Gitblit's web GUI to create a new repository, assign share mode. If you want to block anonymous access, make sure you select "authenticated view, clone & push".
2. Open the repository you just created, and you'll see a link started with https://, click the copy to clipboard icon to copy the link to clipboard
3. Start Git console and navigate to your local Git folder
4. Run below command: ( you shall be able to paste the link from clipboard )
  git remote add origin https://yourpcname:yourport/git/yourrepo
  git push origin master
and bang! you'll hit below error:
  "SSL certificate problem, verify that the CA cert is OK."
This is because Git will verify if the server's certificate is a valid certificate. If you are a poor man as I am, you probably don't have a valid certificate. Set an environment variable will make Git skip the verification step (I put this line in the ~/.bashrc file to avoid type it each time)
  $ export GIT_SSL_NO_VERIFY=true 
  $ git push origin master

This will push you master branch to Gitblit. Then you can go to web UI to verify it.

Another way to overcome this certificate issue is to create your own root certificate, import it as trusted root certificate, then create a certificate and sign it with the root certificate. 

No comments:

Post a Comment