繁体   English   中英

Nuget Package 在 Ubuntu 20.04 上恢复失败,远程证书无效

[英]Nuget Package restore failing on Ubuntu 20.04 with remote certificate is invalid

我有一个 .net 核心 3.1 项目,我正在尝试在 Ubuntu 20.04 虚拟机上构建。

项目构建成功,我现在需要更新项目中的 NuGet 包之一。 一旦我将 .csproj 文件中的 package 版本更改为所需的版本,当我构建或执行“dotnet restore”时,我会收到以下消息:

/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/home/ic/Source/redacted.csproj]
/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error :   The SSL connection could not be established, see inner exception. [/home/ic/Source/redacted.csproj]
/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error :   The remote certificate is invalid according to the validation procedure. [/home/ic/Source/redacted.csproj]

If I browse to https://api.nuget.org/v3/index.json I can successfully view the json in the browser and the certificate appears to be trusted.

我有:

不确定到底是什么真正解决了我的问题,但是,长话短说,我认为以下方法有效:

在 api.nuget.org 上运行 wget 给出:

--2021-12-02 09:38:34--  https://api.nuget.org/v3/index.json
Resolving api.nuget.org (api.nuget.org)... 152.199.40.167
Connecting to api.nuget.org (api.nuget.org)|152.199.40.167|:443... connected.
ERROR: cannot verify api.nuget.org's certificate, issued by 'CN=Microsoft Azure TLS Issuing CA 05,O=Microsoft Corporation,C=US’:
  Unable to locally verify the issuer's authority.
To connect to api.nuget.org insecurely, use `--no-check-certificate'.

在研究该错误的某个时候,我重新安装了 ca-certificates(不确定这是否与解决问题有关):

sudo apt-get install --reinstall ca-certificates

最终,我发现: “dotnet restore”失败,“SSL peer certificate or SSH remote key was not OK”导致我设置 SSL_CERT_FILE 环境变量:

export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

这似乎是关键,现在 dotnet restore 可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM