DotNet not valid certificate found
Asked Answered
A

2

10

I have seen this questions many times, but none of the answers works for me. My DotNet Core app fails

The code:

    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

the error:

System.InvalidOperationException
  HResult=0x80131509
  Message=Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
  Source=Microsoft.AspNetCore.Server.Kestrel.Core

This exception was originally thrown at this call stack:
[External Code]
AccionesWeb.Program.Main(string[]) in Program.cs

When I try to create a cert, it creates it without problem, but then it says not found

PS ...> dotnet dev-certs https -t
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.
The HTTPS developer certificate was generated successfully.

PS ...> dotnet dev-certs https -c
No valid certificate found.

enter image description here

Armrest answered 12/12, 2020 at 14:58 Comment(0)
A
13

I found the solution. I had to manually delete all certs because dotnet dev-certs https --clean was not removing all of them

If you are facing this issue, delete all localhost certificates with friendly name ASP.NET Core... from:

  • Current User > Personal > Certificates
  • Current User > Trusted root certification authorities > Certificates

More info in here

Armrest answered 12/12, 2020 at 15:13 Comment(5)
Tried this and still had no luck. Still says there are no valid certificates when running --checkFluidextract
@DavidPeterson do you have any DotNet certificate in the cert store? let me know if you are not sure how to check itArmrest
I had read through the answer too quickly and realized I missed where you need to check Personal certificates as well. After finding more certs there, I was able to remedy the issue. I had forgot I wrote this, otherwise I would have updated it.Fluidextract
In Mac Os, I deleted the localhost certificates in the System tab.Dwell
Thanks a lot @sudherson for sharing the tip!Armrest
B
0

I had the same error. Running this command, it said no certificate could be found:

PS C:\Users\DanielJonsson> dotnet dev-certs https --check --verbose
[1] Listing certificates from CurrentUser\My
[2] Found certificates: no certificates
[3] Checking certificates validity
[4] Valid certificates: no certificates
[5] Invalid certificates: no certificates
[6] Finished listing certificates.
No valid certificate found.

What I needed to do was:

  1. Close your development environment, in my case Rider.
  2. Open Manage user certificates and delete the certificate named localhost with friendly name ASP.NET Core HTTPS development certificate under Personal > Certificates and Trusted Root Certificate Authorities > Certificates.
  3. Open Manage computer certificates and delete the certificate named localhost with friendly name ASP.NET Core HTTPS development certificate under Personal > Certificates and Trusted Root Certificate Authorities > Certificates.
  4. Run:
    > dotnet dev-certs https --clean
    > dotnet dev-certs https --verbose
    > dotnet dev-certs https -t
    
  5. Start your development environment again.
Blatt answered 7/6, 2024 at 8:57 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.