VS 2019 16.5.0 Preview 5 Windows 10 Chrome Version 80.0.3987.163 (Official Build) (64-bit)
I Googled this and am unable to find an answer.
I am trying to run a simple asp.net core MVC app with TLS on localhost.
What I did is I created a new project then in the project settings I enabled SSL and the URL I got I copied as App URL
App starts properly and TLS CA is not trusted? I followed the example here: https://stackoverflow.com/a/48790088/4950215 and I added the certificated Located in Personal/Certificates
folder to Trusted Root Certification Authorities - Certificates
manage computer certificates now showed that the CA is trusted.
I reloaded the app and I saw that the localhost SSL certificate used by Chrome is different than the one registered on my computer, and therefore the CA is still not trusted.
I have found the issue:
Basically, for whatever reason, I had a localhost installed on my
LocalComputer
store certificates. This made me think that Visual Studio created it, in reality VS creates certificates in theCurrentUser
store, as visible by the open code in the dotnet repo.Typically the procedure, for generating and TLS certificate by VS, is expected to go as such:
A .NET Project is marked as HTTPS, and you try to run it.
VS checks if a certificate is present in the
CurrentUser
store, asks to create one if it's notUser clicks YES, to creating a certificate, initially the certificate is installed in the
CurrentUser/Personal/Certificates store
VS then sees that you do not have a localhost certificate in
CurrentUser/TrustedRootCA/Certificates
, and makes a prompt to ask you if you would like to install one, you click YES - everything is done.Now if for some reason you are like me... and your
CurrentUser/Trusted Root Certification Authority/Certificates
is read only. Then you end up on the following line of the code:Because well step 4 failed...
To mitigate this:
CurrentUser
andLocalComputer
stores. You can do that by following this microsoft guide, or just typecertlm.msc
andcertmgr.msc
in the Start.CurrentUser
store and export it as with the default optionsCurrentUser
store.LocalComputer
store.Now everything should work. Hopefully you wouldn't have spent 6 hours on this, like I did.