作为服务运行时,TFS Build Agent无法在TFS 2017中连接到HTTPS git

Joh*_*ohn 8 git ssl tfs tfs2017

我们在服务器上使用内部证书,我已按照步骤操作

https://blogs.msdn.microsoft.com/tfssetup/2016/12/19/error-ssl-certificate-problem-unable-to-get-local-issuer-certificate/

以及这里的步骤:

https://blogs.msdn.microsoft.com/phkelley/2014/01/20/adding-a-corporate-or-self-signed-certificate-authority-to-git-exes-store/

作为服务运行时出错:

git version
git config --get remote.origin.url
git config gc.auto 0
git config --get-all http.https://ourtfsserver:8443/tfs/path/_git/project.extraheader
git config --get-all http.proxy
git -c http.extraheader="AUTHORIZATION: bearer ********" fetch --tags --prune --progress origin
fatal: unable to access 'https://ourtfsserver:8443/tfs/path/_git/project/': SSL certificate problem: unable to get local issuer certificate
##[error]Git fetch failed with exit code: 128
Run Code Online (Sandbox Code Playgroud)

当使用相同的代理程序配置运行但使用.\ run.cmd而不是作为服务(相同的凭据)时,它可以成功运行:

git version
git config --get remote.origin.url
git config gc.auto 0
git config --get-all http.https://ourtfsserver:8443/tfs/path/_git/project.extraheader
git config --get-all http.proxy
git -c http.extraheader="AUTHORIZATION: bearer ********" fetch --tags --prune --progress origin
git checkout --progress --force {hash here}
(and continues onto next steps)
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用我们的构建代理帐户手动运行它时,它提供与Git fetch failed with exit code: 128上面相同的内容.我可以手动git clone使用这些凭据.

所以我试过了:

git config –global http.sslVerify false
Run Code Online (Sandbox Code Playgroud)

以及手动设置配置文件以包含该变量.

我还使用IE安装了证书,以获得第二篇博文.

我可以手动下拉项目而不会出现问题,我的帐户和构建代理帐户都使用 git clone https://ourtfsserver:8443/tfs/path/_git/project c:\somefolder

我正在使用2017年2月13日的TFS 2017 Update 1 RC2(https://www.visualstudio.com/en-us/news/releasenotes/tfs2017-update1),之前的版本不会让我们的构建代理连接到所有到tfs https正确.我们的旧TFS 2015构建代理仍然有效,但缺少v2代理的新功能.

编辑:使用set HTTP_PROXY=https://localhost:8888我能够让VSTS使用fiddler作为代理并且它提出了一个请求:

CONNECT our.local.tfs.fqdn:8443 HTTP/1.1
Host: our.local.tfs.fqdn:8443
User-Agent: git/2.10.0 (vsts-agent-git/2.112.0)

A SSLv3-compatible ClientHello handshake was found. Fiddler extracted the parameters below.

Version: 3.3 (TLS/1.2)
(bunch of other stuff it decrypted here)
Run Code Online (Sandbox Code Playgroud)

对于Auth它有:

No Proxy-Authorization Header is present.

No Authorization Header is present.
Run Code Online (Sandbox Code Playgroud)

Joh*_*ohn 2

因此,我找到了一个比全局禁用 https 验证更好的命令,希望这会在构建代理的未来更新中得到更好的处理。

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

这只会禁止它在你的(希望是内部的)git 服务器上进行验证。