Custom NuGet feed with invalid certificate
Asked Answered
K

5

6

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.

Kyles answered 1/4, 2020 at 13:2 Comment(2)
@PerryQian-MSFT I could find a work around for that by opening fiddler and set SSL - SECURITY: "Ignore server certificate errors" , present in options dialog.Kyles
How to disable check ?Keil
S
4

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.

Superaltar answered 2/4, 2020 at 9:32 Comment(0)
A
4

I had same problem and my solution is "Download and add certificate to Windows Certificate Manager"

  1. Download *.crt file in browser 2
  2. run MMC.EXE
  3. File, Add Snap-In: Certificates
  4. Import certificate in Local Computer -> Trusted root certificate authorities
  5. Reboot

Aflutter answered 8/6, 2020 at 18:7 Comment(0)
M
1

This solved my problem : Take the untrusted certificate root and put it your users trusted roots. (Be careful, you really have to trust and know this sites :) ) https://www.youtube.com/watch?v=C4Ho9nAaqrE

Medulla answered 3/7 at 12:5 Comment(0)
J
0

Thanks to the two answers above I was able to fix my issue on Windows. The only gotcha I would like to add for others is to check that the entire certificate validation path is valid. This means that the root certificate of the certificate you installed in the Trusted root certificate authorities as DMihaylcihenko highlighted above must also be installed in the Trusted root certificate authorities. Otherwise the certificate validation procedure will keep failing.

Jadwigajae answered 3/4, 2023 at 9:5 Comment(0)
H
0

For me, this error started to pop up during development. VS 2022 was open a while and I had already fetched some packages succesfully. But then all of the sudden I couldn't anymore.

The fix for me was just restarting VS. Hope this will help anyone before you start messing around in your registry :)

Homotaxis answered 20/8 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.