TFS Build Agent failing to connect to HTTPS git in TFS 2017 when running as service

纵然是瞬间 提交于 2019-12-03 13:44:30

This is what I did to resolve the issue.

  • Download latest GIT from https://git-scm.com/downloads

  • During installation setup, select Windows Certificate store for SSL.

  • Go to Program files and copy the latest GIT folder.

  • Replace the git folder inside the agent/externals with the latest GIT folder.

  • Restart agent and build again.

Peter

I ran into this problem as well. Are you sure you updated the correct custom trust-store? The one in the agent directory \externals\git\mingw64\ssl\certs\ca-bundle.crt ? This seems to be the one that the agent uses nowadays. So even though your system git may be working fine, the agent won't use that and thus won't trust your self-signed SSL cert.

update: if that fails too, you could try running the git.exe in there and setting the sslVerify flag to false, e.g.:

C:\agent\externals\git\cmd\git.exe config --global http.sslVerify false

So I found a better command than disabling https verification globally, hopefully though this will be better handled in future updates to the build agent.

git config --global http."https://YOURTFS.SERVER.HERE:PORT/".sslVerify false

That will only disable it from verifying on your (hopefully internal) git server.

I have an internally issued cert (not self-signed) for TFS. Here are the steps I took to get this working for my scenario:

  1. I followed step 1 of this guide, then dropped the exported cert into the certs folder, which looked something like this: E:\agent\1\externals\git\mingw64\ssl\certs.
  2. After that, I followed the directions here to set the git config. The command(s) for that looked like this:

    git config --global http."https://tfs/tfs/".sslCAInfo "path\to\cert\certificate.cer"
    git config --system http."https://tfs/tfs/".sslCAInfo "path\to\cert\certificate.cer"
    
  3. The last thing I did was restart the agent service and everything was fine after that.

EDIT: I'm also running the agent under a build service domain account.

fatal: unable to access <server>: SSL certificate problem: unable to get local issuer

Sometimes running the following command appears to work but it hasn't!

C:\agent\externals\git\cmd\git.exe config --global http.sslVerify false

To check what I mean run this:

git config --list --show-origin

This will list all the Git Config files on the PC.

What worked for me is checking the c:\ProgramData/Git/config file.

I had to format mine (newlines and Tabs) and manually had to add the sslVerify and the sslCAInfo (for some reason in this environment they weren't getting set).

[core]  
    symlinks = false  
    autocrlf = true  
    fscache = true  
[color]  
    diff = auto  
    status = auto  
    branch = auto  
    interactive = true  
[pack]  
[help]  
    format = html  
[http]  
    sslVerify = false  
    sslCAInfo = C:/Program Files (x86)/Microsoft Visual 
Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/mingw32/ssl/certs/ca-bundle.crt  
[diff "astextplain"]  
    textconv = astextplain  
[rebase]  
    autosquash = true  

This allows a Service Account (with no login rights) to access the Git repo.

I learnt that VS2017 doesn't play well with Gits ca-bundle: https://developercommunity.visualstudio.com/content/problem/48517/visual-studio-2017-ssl-certificate-problem-unale-t.html

Instead of this:

sslcainfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

I use this:

sslCAInfo = C:/Program Files (x86)/Microsoft Visual 
    Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/mingw32/ssl/certs/ca-bundle.crt  

Obviously when you get this going remove sslVerify = false

Since you can't manually using the build agent account to run the command. Please double check if you or your mates ever modified the permission for "Project Collection Build Service" account. If you do not have, please add one.

Also confirm your build agent version, make sure have updated to the latest. You could use another new build agent instead of this one to narrow down the issue.

If above couldn't figured out the issue, you may need some more diagnostic info such as give a Fiddler trace.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!