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.