简体   繁体   English

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

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

I have a .net core 3.1 project I am attempting to build on an Ubuntu 20.04 virtual machine.我有一个 .net 核心 3.1 项目,我正在尝试在 Ubuntu 20.04 虚拟机上构建。

The project was building successfully, I now need to update one of the NuGet packages in the project.项目构建成功,我现在需要更新项目中的 NuGet 包之一。 Once I change the package version in the.csproj file to the required version, when I either build or perform "dotnet restore" I get the following message:一旦我将 .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. 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.

I have:我有:

Not sure in the end what actually solved my problem, but, long story short, I think the following worked:不确定到底是什么真正解决了我的问题,但是,长话短说,我认为以下方法有效:

Running wget on api.nuget.org gave:在 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'.

At some point in researching that error, I reinstalled ca-certificates (not sure if that has anything to do with resolving the problem):在研究该错误的某个时候,我重新安装了 ca-certificates(不确定这是否与解决问题有关):

sudo apt-get install --reinstall ca-certificates

Ultimately, I found: "dotnet restore" fails with "SSL peer certificate or SSH remote key was not OK" which led me to setting the SSL_CERT_FILE environment variable:最终,我发现: “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

That seems to have been the key and dotnet restore now works correctly.这似乎是关键,现在 dotnet restore 可以正常工作。

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

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