簡體   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