Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble trusting local HTTPs certificate in ASP.NET Core

I am following an online tutorial to create an ASP.NET Core Web application. I followed everything but had trouble with trusting the local HTTPS certificate.

When I first run the application, I got an error saying: "the access control list (acl) structure is invalid"

I tried googling this error but couldn't find anything related to my ASP.NET application, after cleaning the solution I didn't get this error any longer.

But I was unable to run my application in browser using HTTPS as it always says: "This site is not secure"

I tried to trust certificate using CMD using this command:

dotnet dev-certs https --trust

It should show me a prompt to trust the certificate but it says "there was an error trusting the HTTPS developer certificate" and the application runs in an unsafe mode on the browser.

Can someone please help me run my application with HTTPS on my local environment? Any help will be greatly appreciated. Thanks

like image 511
AhsanAzeem Avatar asked Jun 01 '19 18:06

AhsanAzeem


2 Answers

This seems to be a bug in ASP.NET Core 2.1:

what you need to do is go move your added certificates from your certificate manager.

go to start menu > Type "Ctrl + R" type "certlm.msc", this will open your certificate manager.

go to Personal/Certificates

you will find a certificate named "localhost there.

Move that to "Trusted Root Certification Authorities/Certificates"

run the project again, and it should work.

Hope this helps.

like image 151
Zeeshan Adil Avatar answered Sep 18 '22 01:09

Zeeshan Adil


I had the same problem in .NET 5. Running the command gave me the same error. After a few iterations I figured it out finally...

I was trying to create certificates manually through certlm.msc (local computer) but apparently the certificate should be created in certmgr.msc (current user). This is the place where the certificate gets saved when you run the command dotnet dev-certs https --trust.

  1. Windows + R and type certlm.msc
  2. Go to Personal -> Certificates and export the localhost certificate with the same key (asks for password)
  3. Go to Trusted Root Certification Authorities -> Certificates and right-click to click on Import
  4. Browse and select the exported certificate
  5. Place all certificates in the following store is selected and click on Browse again
  6. Mark the checkbox: Show physical stores
  7. Click on Trusted Root Certification Authorities and press on Local Computer
  8. Finish everything
like image 20
Giga Meta Avatar answered Sep 19 '22 01:09

Giga Meta