How do I set GIT_SSL_NO_VERIFY for specific repos only?

前端 未结 11 1957
迷失自我
迷失自我 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 03:51

    On Linux, if you call this inside the git repository folder:

    git config http.sslVerify false
    

    this will add sslVerify = false in the [http] section of the config file in the .git folder, which can also be the solution, if you want to add this manually with nano .git/config:

    ...
    [http]
      sslVerify = false
    
    0 讨论(0)
  • 2020-12-02 03:53

    Like what Thirumalai said, but inside of the cloned repository and without --global. I.e.,

    1. GIT_SSL_NO_VERIFY=true git clone https://url
    2. cd <directory-of-the-clone>
    3. git config http.sslVerify false
    0 讨论(0)
  • 2020-12-02 03:54

    If you have to disable SSL checks for one git server hosting several repositories, you can run :

    git config --bool --get-urlmatch http.sslverify https://my.bad.server false
    

    (If you still use git < v1.8.5, run git config --global http.https://my.bad.server.sslVerify false)

    Explanation from the documentation where the command is at the end, show the .gitconfig content looking like:

    [http "https://my.bad.server"]
            sslVerify = false
    

    It will ignore any certificate checks for this server, whatever the repository.

    You also have some explanation in the code

    0 讨论(0)
  • 2020-12-02 03:54

    for windows, if you want global config, then run

    git config --global http.sslVerify false
    
    0 讨论(0)
  • 2020-12-02 04:03

    If you are on a Windows machine and have the Git installed, you can try the below steps:

    1. Go to the folder of Git installation, ex: C:\Program Files (x86)\Git\etc
    2. Edit the file: gitconfig
    3. Under the [http] section, add the line: sslVerify = false

      [http]
        sslVerify = false
      
    0 讨论(0)
  • 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\\<user>\\repo.your-server.com.cer
    # unix path to certificate (Base64 encoded)
    sslCaInfo = /home/<user>/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

    0 讨论(0)
提交回复
热议问题