(git tfs fetch) TF400324: Team Foundation 服务不可用,底层连接已关闭

(git tfs fetch) TF400324: Team Foundation services are not available, The underlying connection was closed

我已经使用 git-tfs 将近 5 年了,然后有一天我在 运行 git tfs fetch:

时遇到以下错误
TF400324: Team Foundation services are not available from server https://tfs.company.com/tfs/foo.
Technical information (for administrator):
  The underlying connection was closed: An unexpected error occurred on a send.
The underlying connection was closed: An unexpected error occurred on a send.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host

我什至打开 Fiddler 查看发生了什么,当我的笔记本电脑尝试连接时,TFS 服务器确实断开了套接字。

在与我们的一位服务器管理员交谈后,我发现我们的 TFS 服务器已禁用对 TLS 1.0 的支持,我想我有确凿的证据。我认为我的笔记本电脑正在尝试使用 TLS 1.0 连接到我们的服务器,这当然会导致服务器关闭套接字。

如何更改 git tfs 在连接到 Team Foundation Services 时使用的 TLS 版本?

我想通了,我怀疑在 Team Foundation Servers 上禁用 TLS 1.0 是问题的根源。在谷歌搜索 git tfs tls 1.0 后,我偶然发现了 Enabling strong cryptography for all .Net applications,这让我找到了解决办法。您需要为 .NET 应用程序启用强加密(呃,标题中是这么说的)。

  1. 打开 PowerShell 命令提示符,运行 提升权限

  2. 运行 64 位应用程序的以下命令:

    # set strong cryptography on 64 bit .Net Framework (version 4 and above)
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
    
  3. 运行 此命令适用于 32 位应用程序

    # set strong cryptography on 32 bit .Net Framework (version 4 and above)
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
    
  4. 重启。

现在我的机器正在愉快地从 TFS 中提取大约一百个 check-ins。

我没有太多关于 TFS 的技术知识,但每天我都必须从 Visual Studio 签入我的代码,最近我遇到了这个问题。这里提到的上述解决方案,来自我的 head.So,我尝试了一种更简单的方法:

  1. 注销然后通过团队-> 管理连接再次登录到 TFS。
  2. 再次映射我的项目。

瞧!我成功签入了我的代码。也许这会对其他人有所帮助