Recently, my localhost certificate is expired, I have gone to "sertmgr.msc" remove all localhost certificate and restart the VS and add a new localhost certificate to windows. But when am I running my application again, still use the old expired certificate not the new one, does anyone know how to fix that? I have already run the command show below.
dotnet dev-certs https --clean
dotnet dev-certs https --trust
Expired Cert Cert In Cert Manage
When using an expired certificate, you risk your encryption and mutual authentication. As a result, both your website and users are susceptible to attacks and viruses. For example, a hacker can take advantage of a website with an expired SSL certificate and create a fake website identical to it.
Removing Cookies in Google Chrome It will load all cookies for the website. Now use Remove All Shown to delete all cookies or use the Trash bin icon to delete one by one. This should fix the error, This certificate has expired or is not yet a valid error.
You might have to distribute the updated certificates to other client/server systems as well, depending on the type of SSL negotiation being used. To avoid this, take actions to renew certificates before they expire. Renewal updates are much simpler and less disruptive to process.
Answer. If you use S/MIME to sign or encrypt email messages, you should not delete your personal certificate, even after it expires. Doing so would cause you to permanently lose access to those messages.
I managed to hack my way around this issue:
Before you do anything, clean the old certificate and generate a new trusted one.
dotnet dev-certs https --clean
dotnet dev-certs https --trust
And if the process above fails, manually remove the certificates before retrying the clean/trust commands.
Get the User Secrets ID of the Web Application you're having trouble with. Search for UserSecrets.UserSecretsIdAttribute(" in your project folder and take the GUID.
Go to %APPDATA%\Microsoft\UserSecrets
and open the folder containing the GUID of the problematic project you are struggling with and leave it open.
Create a new Asp .Net Core project, get its secrets
GUID, go to the corresponding secret folder (%APPDATA%\Microsoft\UserSecrets\GUID
), and open the file secrets.json
. You should see something like this
{
"Kestrel:Certificates:Development:Password": "8353f2ec-3cc0-4052-9776-9585b6abd346"
}
Copy that setting from the newly created project secrets.json
and use it to override the development password on the secrets.json
of the broken project
This way, I've managed to get my old project to use the newly generated certificate. It is hacky, but it works
I assume you're using IIS Express to host your application. If so, it sounds like you're missing linking the certificate to your application(s) as described in this blog post:
Go to C:\Program Files (x86)\IIS Express
and run the following from the command line, entering the proper port number and the new certificate thumbprint:
IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:PORT/ -CertHash:THUMB
Based on Pedro's answer,
I used:
dotnet dev-certs https --clean
dotnet dev-certs https --trust
to clean/replace the old certs.
Then I went to:
%APPDATA%\Microsoft\UserSecrets
And deleted all the folders found there.
Now my application runs without complaining. Creating a new .net core 6 application and running it didn't create a new folder, so I don't know if it's no-longer required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With