Share via

Expired certificate

M J 681 Reputation points
2026-04-01T18:39:28.6133333+00:00

I am trying to run my code in debug mode. When iIclick F5 it opens a browser instance showing a certificate notice.

I have tried the following steps to resolve this

  • Closed all browsers and Visual Studio
  • Deleted .vs folder from the repos/myProjectFolder
  • Deleted applicationhost.config
  • opened certmgr.msc under Personal-> Certificates deleted the localhost certificate under Trusted Root Certification Authorities -> Certificates deleted the localhost certificate (it shows 3/31/2026 as Expiration Date)
  • opened Developer Command Prompt and then entered dotnet dev-certs https --clean then dotnet dev-certs https --trust to build new certificate
  • opened my project in Visual Studio clicked F5 to run it, and was prompted about the new cert said yes prompted again and said yes again and still I see the certificate notice by the browser.

When I next check everything in certmgr.msc I now see my new certificate set to expire on 4/1/2027 but I also once again see the old expired one that I deleted I delete it, try to open the project and it puts it back in there.

What do I need to do to resolve this???

Developer technologies | Visual Studio | Debugging
0 comments No comments

1 answer

Sort by: Most helpful
  1. Gade Harika (INFOSYS LIMITED) 2,605 Reputation points Microsoft External Staff
    2026-04-02T03:31:44.42+00:00

    Thanks for reaching out.
    This happens because Visual Studio is still using an expired HTTPS development certificate cached outside the Windows certificate store. Deleting certificates from certmgr.msc alone is not sufficient.

    Please follow these steps:

    1. Close Visual Studio completely
    2. Delete all files from: %APPDATA%\ASP.NET\Https
    3. Remove User Secrets for this project:
      • Open the .csproj file and note the <UserSecretsId>
        • Delete the corresponding folder from:
          %APPDATA%\Microsoft\UserSecrets<UserSecretsId>
        1. Open Developer Command Prompt as Administrator and run:
        dotnet dev-certs https --clean
        dotnet dev-certs https --trust
    4. Reopen Visual Studio and press F5, then trust the new certificate when prompted.

    After this, the expired localhost certificate should no longer reappear, and the browser certificate warning should be resolved.

    Let me know if you need any further help with this. I will be happy to assist. If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.