AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

回答1

Please check below points:

  1. Installing the .NET Core SDK installs the ASP.NET Core HTTPS development certificate to the local user certificate store as part of the first-run experience, but it is not trusted. To trust the certificate, perform the one-time step to run the dotnet dev-certs tool.
  2. Check the certificates in the certificate store.Find localhost certificate with the ASP.NET Core HTTPS development certificate both under Current User > Personal > Certificates and Current User > Trusted root certification authorities > Certificates
  3. Try to remove all found certificates by checking carefully from both Personal and Trusted root certification authorities.

Note: Do not remove the IIS Express localhost certificate.

Try to run the following commands in .NET CLI and try again

dotnet dev-certs https --clean
dotnet dev-certs https --trust

Note: Untrusted certificates should only be used during app development. Production apps should always use valid certificates.

References:

  1. Trust the ASP.NET Core HTTPS development certificate on Windows and macOS
  2. Enforce HTTPS in ASP.NET Core | Microsoft Docs

 

Windows - certificate not trusted

  • Check the certificates in the certificate store. There should be a localhost certificate with the ASP.NET Core HTTPS development certificate friendly name both under Current User > Personal > Certificates and Current User > Trusted root certification authorities > Certificates
  • Remove all the found certificates from both Personal and Trusted root certification authorities. Do not remove the IIS Express localhost certificate.
  • Run the following commands:
dotnet dev-certs https --clean
dotnet dev-certs https --trust

Close any browser instances open. Open a new browser window to app.

 

posted @ 2022-12-07 17:32  ChuckLu  阅读(713)  评论(0编辑  收藏  举报