Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am performing a task to authenticate a Active-directory B2C instance in Azure from a local ToDo WebApp using a local WebAPI service.

I have created 2 Apps App1 and App2, apart from adding a B2C instance in a trial-version subscription of Azure. In local windows 10 OS, in Visual-Studio, I collected code for the ToDo Webapp and WebAPI Service as per a Microsoft-blog here

However, when I start the WebAPI service, and run the ToDoWebapp, the login after creating a user works fine, but after that, for any call to the service, I get the error-page with the message: AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

HttpRequestException: The SSL connection could not be established, see inner exception.

How can one resolve this error?

like image 996
Nishanth Battula Avatar asked Dec 13 '25 06:12

Nishanth Battula


1 Answers

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
like image 186
kavya Saraboju Avatar answered Dec 15 '25 22:12

kavya Saraboju



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!