Score:0

NuGet `dotnet restore` doesn't work on Ubuntu 20.04 (Linux Mint 21) due to errors in the certificate chain

jm flag

When I try to make a simple Unit Test project with the following command (inside a project folder called test):

dotnet new xunit

It fails and this is the output I get:

/usr/share/dotnet/sdk/5.0.301/NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/home/user/Desktop/test/test.csproj]
/usr/share/dotnet/sdk/5.0.301/NuGet.targets(131,5): error :   The SSL connection could not be established, see inner exception. [/home/user/Desktop/test/test.csproj]
/usr/share/dotnet/sdk/5.0.301/NuGet.targets(131,5): error :   The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot [/home/user/Desktop/test/test.csproj]

It also tells me to manually restore NuGet packages using dotnet restore which yields the same error messages as before. Thus I did some research to see what this is all about and how to fix it and there was an official article by Microsoft addressing the issue. In the article they mention how it got fixed in the SDK version that was released just prior to mine, so it should've still been the case given that I have the newer version. But just in case I also installed the previous version and the .NET 3.1 version of the SDK and runtime but got the same error messages as before.

Doing some further research I saw people suggesting that I update my ca-certificates which I did using:

update-ca-certificates (--fresh)

Which once again did not help. But there was a discussion about this issue here and how to resolve it on Debian. So I was wondering can the same fix be used on Ubuntu? And how do I update the package to use the newest version?

That's what I've tried thus far, but none of it had worked.

guiverc avatar
cn flag
Only Ubuntu and official flavors of Ubuntu (https://ubuntu.com/download/flavours) are on-topic here, refer to https://askubuntu.com/help/on-topic where you'll find other SE sites where you question will be welcome if you don't want to use a Mint forum. (*One advantage of Ubuntu is it's many support options, you opted for Mint so take advantage of it's support options, or SE Unix & Linux*)
jm flag
Right, but the same issue exists on the normal Ubuntu 20.04 as is stated in the article I've provided. So the fix would be the same.
Muizz Mahdy avatar
jp flag
@adadaae12313412 1) Install the latest ca-certificates from here http://deb.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20210119_all.deb 2) Follow the first and second answers of this question: https://askubuntu.com/questions/645818/how-to-install-certificates-for-command-line
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.