When a web project is created, Visual Studio automatically generates a SSL certificate and prompts you to install it. Everything works fine.
That certificate has now expired and I cannot figure out how to get it to re-generate one and start the process over again. I’ve tried deleting all existing localhost
certificates from the certificate store and deleting secrets.json, but nothing seems to force it to re-start the generation process.
3
Answers
I finally figured it out.
For anyone else who runs into this, the steps to fix it are:
localhost
certificates must be deleted in certificate manager. They can be found in Personal and Trusted RootUsers[user]AppDataRoamingMicrosoftUserSecrets
dotnet dev-certs https --trust
to create and install a new one with the prompt to trustIt will work after this again.
From Visual Studio 2022 > Tools > Nuget Package Manager > Package Manager Console
When the Package Manager Console display appears at the bottom, then type the command below
Look at here for details
I spent days trying to solve this and none of the above answers worked for me. The expired certificate didn’t exist anywhere when searching in the Microsoft Management Console. After running the
dotnet dev-certs https --clean
and--trust
commands, the certificate used by my browsers was still expired.The solve for me was navigating to
%APPDATA%ASP.NEThttps
orC:Users{user}AppDataRoamingASP.NEThttps
and removing the certificates there. They should have your project name i.e.myproject.key
andmyproject.pem
. Delete those files, then rebuild and run your project. This should automatically generate new versions of the files and the browser should pick up the new certificate.Thanks to this post for providing the fix!