How do I set GIT_SSL_NO_VERIFY for specific repos only?

前端 未结 11 2022
迷失自我
迷失自我 2020-12-02 03:12

I have to use a git server without proper certificates, but I don\'t want to have to do

env GIT_SSL_NO_VERIFY=true git command

every single

11条回答
  •  臣服心动
    2020-12-02 04:04

    There is an easy way of configuring GIT to handle your server the right way. Just add an specific http section for your git server and specify which certificate (Base64 encoded) to trust:

    ~/.gitconfig

    [http "https://repo.your-server.com"]
    # windows path use double back slashes
    #  sslCaInfo = C:\\Users\\\\repo.your-server.com.cer
    # unix path to certificate (Base64 encoded)
    sslCaInfo = /home//repo.your-server.com.cer
    

    This way you will have no more SSL errors and validate the (usually) self-signed certificate. This is the best way to go, as it protects you from man-in-the-middle attacks. When you just disable ssl verification you are vulnerable to these kind of attacks.

    https://git-scm.com/docs/git-config#git-config-httplturlgt

提交回复
热议问题