问题现象

在 WSL 或 Windows 中访问 GitHub 时出现 TLS 错误。

为了排除”WSL 没有连接 Windows 网络”的可能,在两边分别测试:

Terminal window
1
curl -I https://github.com # WSL
2
curl.exe -I https://github.com # Windows

两边均报错,说明问题不在 WSL 网络隔离,而是更上层的原因。

报错信息:

1
gnutls_handshake() failed: The TLS connection was non-properly terminated

问题原因

该问题通常不是 Git 或 WSL 的配置错误,而是代理节点异常导致 TLS 握手失败。

典型特征:

  • ping google.com 返回 198.18.x.x,说明代理已开启,Windows 梯子也在工作
  • curl https://github.com 失败
  • 浏览器可能可以访问,但命令行工具失败

原因:当前代理节点可以建立连接,但无法完成 TLS 握手,节点本身出了问题。

解决方案

在 Clash for Windows 中切换节点:

  1. 打开 Proxies
  2. 切换到 Developer(开发节点组)
  3. 更换一个节点(如 US / TW / Fast 等)
  4. 重新测试:
Terminal window
1
curl -I https://github.com

返回以下内容说明问题已解决:

1
HTTP/2 200

适用场景

适用于 WSL、Git、npm / pnpm、Docker、GitHub API、curl / wget 等命令行工具访问 GitHub 的场景。