asp.net-core.net-coreopensslvisual-studio-macmacos-high-sierra

Visual Studio 2019 Mac keeps asking for HTTPS developer certificate


had to ask cause I can't seem to find any solutions to my problem.

I just installed .NET Core 5.0.401 on my mac running OS X 10.13.6 and created a project in Visual Studio Community 2019 using the ASP.NET Web Application (Model-View-Controller) template. Whenever I try to run the project VS tells me the HTTPS development certificate was not found and asks me to create and trust a new one. If I go ahead and click on "install and trust" it prompts me for password, once entered it starts building the project and throws this exception: "Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date"

Screenshot of the exception thrown

At first I thought it would only happen the first time I had to run the project, but the same happens each time I run it. The thing is, this is happening even after successfully running dotnet dev-certs https --trust from the terminal beforehand, and each time VS can't seem to find the certificate.

Screenshot of VS asking to install and trust the certificate

Another important thing, the certificate was not present on Keychain Access upon installation, I had to find a way to get it on there by myself and after many failed attempts with OpenSSL I eventually got a working one using this script I found on GitHub (thanks to whoever made it!). This script was the only way I could get dotnet dev-certs https to return something else than "There was an error saving the HTTPS developer certificate to the current user personal certificate store", before using this script, even though the certificate I had generated was listed in Keychain Access I could never get dotnet dev-certs to find it.

Screenshot of the dotnet dev-certs error prior using the script above

TL;DR: .NET Core installation didn't create the certificate, had to create it myself, dotnet dev-certs now sees and validates the certificate but VS can't seem to find it and keeps throwing the same error.

It's my first foray into .NET Core and VS Community on Mac so it might as well be a very noob problem as far as I know, can any of you help me with this? Has this happened to anybody else?

Thanks in advance!

Edit: I already tried running dotnet dev-certs https --clean and creating a new certificate, and that does nothing. Same for manually deleting the localhost certificate from Keychain Access, cause once I do that I still can't generate the certificate from the command line tool and I have to run the script in order to create it again.


Solution

  • Well I am using Ventura 13.4.1 I tried the usual steps to find online I'd always get the same certificate with the expiry notice on browsers and - of course skipped scripts and other issues

    I ended up creating one new project and to my surprise it used the new certificate that was created on the terminal

    so the only thing I could think of is to compare project files in xml and I found the key related to manage user secrets - with a guid on it - which didn't exist on the newly created project file

    Since I didn't use that feature I just removed that xml node, once I removed that It picked the new Certificate and it worked just fine

    I can finally test secure code again and have no annoying warnings or skipped js files

    I am hoping this is reproducible for you, but it's def. worth a try