Search code examples
.netvisual-studionuget

Custom NuGet feed with invalid certificate


How do I disable SSL certificate check with nuget command?

PS C:\Softwares> .\nuget.exe list

Unable to load the service index for source https://asd.ca/api/feeds. An error occurred while sending the request. The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. The remote certificate is invalid according to the validation procedure.

Please note that I am not planning to upload new package, just wanted to restore my .net packages.


Solution

  • I think this issue is related to your NuGet Package source feed https://asd.ca/api/feeds or some settings which conflicts with it due to some reasons.

    You can try these steps:

    First, make sure that you can access https://asd.ca/api/feeds and can get any request from it and troubleshoot the problem that are not feed addresses.

    Second, open VS and make sure that the URL https://asd.ca/api/feeds is checked under Tools-->Options-->Nuget Package Manager--> Package Source and all the urls which are used to restore the nuget packages of your solution are checked.

    1. clean the NuGet cache or delete the packages folder under C:\Users\xxxx\.nuget

    2. open registry editor and then Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client and change the value of this key DisabledByDefault to 1.

    3. run PowerShell as administrator and then type these:

      reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64
      reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32
      

      For more info you can refer to this link.

      Also try this function in PowerShell :

      nuget trusted-signers Add -Name xxxxxxx(package source name) -ServiceIndex https://asd.ca/api/feeds
      

      You can also refer to this link.

    4. try to change to use another domain on internet Explorer in case the current domain is restricted by certain tools.

    5. go to Settings( Global Settings of your PC ) --> Network and Internet --> Proxy --> Automatic Proxy Setup --> and set Automatically detect settings to off.