DotNet NuGet 推送导致 PowerShell 出现 TLS 错误

DotNet NuGet push causes TLS error on PowerShell

我们在将包发布到 Nuget 的 CI/CD 管道中遇到问题。

正在 PowerShell 上执行此命令:

& dotnet nuget push "*.nupkg" --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate

导致以下输出:

error: Não é possível carregar o índice de serviço para a origem https://api.nuget.org/v3/index.json.
error:   The SSL connection could not be established, see inner exception.
error:   Unable to read data from the transport connection: Foi forçado o cancelamento de uma conexao existente pelo host remoto..
error:   Foi forçado o cancelamento de uma conexao existente pelo host remoto.

我们之前已经尝试过执行:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bOR [Net.SecurityProtocolType]::Tls12

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

我们正在使用 Windows Server 2012。已经更改了注册表项以也使用 Tls12。

编辑:

MSFT Edge // IE

Internet Explorer 设置

我在几周前使用以下注册表项解决了错误:

reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64
reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32