aspnetcore: There was an error trusting HTTPS developer certificate.

I have issue with trusting the HTTPS certificate for .NET Core development.

I tried to trust the certificate from Visual Studio and from dotnet dev-certs tool from the administrator PowerShell. Both fail.

dotnet dev-certs https --trust -v
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
Listing 'HTTPS' certificates on 'CurrentUser\My'.
'1' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
CN=localhost - A67EEAF595CD2AE44B9296F21BC03B8847D18C0F - 24. 4. 2020 14:51:37 - 24. 4. 2021 14:51:37 - True
Checking certificates for validity.
Listing valid certificates
'1' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
CN=localhost - A67EEAF595CD2AE44B9296F21BC03B8847D18C0F - 24. 4. 2020 14:51:37 - 24. 4. 2021 14:51:37 - True
Listing invalid certificates
'0' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
Listing 'HTTPS' certificates on 'LocalMachine\My'.
'0' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
Checking certificates for validity.
Listing valid certificates
'0' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
Listing invalid certificates
'0' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
Filtering found certificates to those with a subject equal to 'CN=localhost'
'1' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
CN=localhost - A67EEAF595CD2AE44B9296F21BC03B8847D18C0F - 24. 4. 2020 14:51:37 - 24. 4. 2021 14:51:37 - True
Listing certificates excluded from consideration.
'0' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
Found valid certificates present on the machine.
'1' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
CN=localhost - A67EEAF595CD2AE44B9296F21BC03B8847D18C0F - 24. 4. 2020 14:51:37 - 24. 4. 2021 14:51:37 - True
Selected certificate
'1' found matching the criteria.
SUBJECT - THUMBPRINT - NOT BEFORE - EXPIRES - HAS PRIVATE KEY
CN=localhost - A67EEAF595CD2AE44B9296F21BC03B8847D18C0F - 24. 4. 2020 14:51:37 - 24. 4. 2021 14:51:37 - True
Trying to export the certificate.
Trusting the certificate on Windows.
Adding certificate to the store.
There was an error trusting the certificate.
Exception message: Access is denied.
There was an error trusting HTTPS developer certificate.
dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.103
 Commit:    6f74c4a1dd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.103\

Host (useful for support):
  Version: 3.1.3
  Commit:  4a9f85e9f8
error01

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 21 (9 by maintainers)

Most upvoted comments

Well, thanks, I have only paid 2000 EUR for the license of Visual Studio and it cannot even run simple website.

I had a similar issue with my private computer (no domain) and solved it with the solution from here: https://serverfault.com/questions/1008035/unable-to-import-certificate-into-user-trusted-root-certificate-store

I also removed all previous added ASP certificates in Personal.

dotnet dev-certs https --clean

After setting the group policy and restarting my computer I could add the dev certificate with dotnet dev-certs to the Trusted Root Certification Authorities. Now starting the project in Visual Studio is working without any issues.

dotnet dev-certs https --trust

Maybe this will help you also.