我有一個 .net core 3.1 專案,我試圖在 Ubuntu 20.04 虛擬機上構建。
專案已成功構建,我現在需要更新專案中的 NuGet 包之一。一旦我將 .csproj 檔案中的包版本更改為所需的版本,當我構建或執行“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]
如果我瀏覽到https://api.nuget.org/v3/index.json我可以在瀏覽器中成功查看 json 并且證書似乎是可信的。
我有:
- 更新的軟體包(apt-get update 和 apt-get upgrade)
- 更新的 NuGet
- 根據此問題中的更新在 NuGet.Config 中設定證書縮略圖:由于證書問題,解決 Devops 構建代理中的 Nuget 包問題
- 我可以在 Ubuntu 上的受信任證書中看到 nuget.org 的 DigiCert 根證書
uj5u.com熱心網友回復:
不確定到底是什么真正解決了我的問題,但是,長話短說,我認為以下方法有效:
在 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 證書(不確定這是否與解決問題有關):
sudo apt-get install --reinstall ca-certificates
最終,我發現:“dotnet restore”因“SSL peer certificate or SSH remote key is not OK”而失敗,這導致我設定 SSL_CERT_FILE 環境變數:
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
這似乎是關鍵,dotnet restore 現在可以正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/376369.html
標籤:C# 。网 ssl 金块 ubuntu-20.04
