How to resolve nuget error SSL connection on Linux Mint 20?

Viewed 1108

I am getting an error when I try to load a simple project using .NET 5.0. Apparently, it is on the Nuget package.

All answers which I have searched not worked for me, their problems it seems because of proxy settings. Be noticed that I am not under a proxy which means I have full access to all websites including de nuget.org

I am just doing this:

dotnet run

and aI getting these errors:

dotnet/sdk/5.0.101/NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json.

dotnet/sdk/5.0.101/NuGet.targets(131,5): error : The SSL connection could not be established, see inner exception.

dotnet/sdk/5.0.101/NuGet.targets(131,5): error : The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

I believe is something because of the TLS certificate, not sure.

Important Tips: On .Net Core 3.1 works I am using Linux Mint 20 (Based on Ubuntu)

My OpenSSL config:

OpenSSL 1.1.1g 21 Apr 2020

Here the output of my .net info

 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     linuxmint
 OS Version:  20
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.101/

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  2.1.811 [/usr/share/dotnet/sdk]
  2.2.402 [/usr/share/dotnet/sdk]
  3.1.404 [/usr/share/dotnet/sdk]
  5.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.23 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.23 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.23 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]```


1 Answers

As I had a similar issue with an invalid certificate chain. More specifically in my case was:

The SSL connection could not be established, see inner exception. The remote certificate is invalid because of errors in the certificate chain: PartialChain

I found a GitHub thread that discusses certificate issues on a Unix machine. Which gave me a response that provided in one of the comments a solution that resolved my issue:

sudo update-ca-certificates  --fresh

The command provided a working solution for my issue and it could be a possible solution for the mentioned problem.

The command update-ca-certificates updates the directory /etc/ssl/certs that holds the SSL certificates and generates ca-certificates.crt, a concatenated single-file list of certificates. It reads the file /etc/ca-certificates.conf.

Each line gives a pathname of a CA certificate under /usr/share/ca-certificates that should be trusted. Lines that begin with "#" are comment lines and thus ignored. Lines that begin with "!" are deselected, causing the deactivation of the CA certificate in question. Certificates must have a .crt extension in order to be included by update-ca-certificates.

Additionally --fresh Removes symlinks in /etc/ssl/certs directory.

Related