3

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.

yungfox
  • 33
  • 4
  • I would try stopping VS Mac, then from the terminal app run `dotnet dev-certs https --clean` and then run `dotnet dev-certs https --trust`. VS Mac runs `dotnet dev-certs https --check` to see if the certificate has been created by dotnet (this returns an exit code and no text output). If this does not work another workaround is to go to the macOS key chain and delete the localhost certificates created, then re-run the dev-certs --trust again to see if that fixes it. – Matt Ward Sep 21 '21 at 11:25
  • 1
    Thanks for your reply! Sadly, I've already tried all the things you mentioned. ```dotnet dev-certs https --clean``` doesn't seem to do anything substantial, and running ```dotnet dev-certs https --trust``` again after deleting the localhost certificate from Keychain Access still doesn't generate the certificate. – yungfox Sep 21 '21 at 19:11
  • If you have managed to fix it please let me know how ! I have a variation of teh same issue, my certificate which was automatically created by vs for mac expired today - although I also ran the same commands clean trust and check and I now have a new certificate that I can use for other new projects the current project that I am working on doesn't work Thank you .. – Amir Magdy Jul 04 '23 at 16:40
  • 1
    @AmirMagdy literally the only thing that worked for me was to change machine altogether :v never got round to fix it on my 2013 macbook, got a new one and everything worked at first try without a itch... even tried to upgrade to vs 2022, bumped dotnet version but no go. what OS version are you on? – yungfox Jul 06 '23 at 07:28
  • Well I am using Ventura 13.4.1 I tried everything - 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 this key something that said secure storage or so with a guid on it - that was not on the newly created project - 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 - – Amir Magdy Jul 08 '23 at 06:51
  • @AmirMagdy that's good to know! if you wanna put in a separate answer i'll mark it as completed so it might be more visible to somebody running into the same problem – yungfox Jul 09 '23 at 09:24

2 Answers2

0

I recently ran into the same problem on an M1 MBP. I tried some online solutions before stumbling across Microsoft's troubleshooting documentation.

Deleting the certificate, cleaning and then trusting worked for me.

  • Find the localhost certificate in the system keychain
  • Remove the localhost certificate
  • Run the following commands:
    dotnet dev-certs https --clean
    dotnet dev-certs https --trust
    dotnet dev-certs https --check
    
DaveBagler
  • 351
  • 3
  • 8
  • 2
    Sadly that's nothing new to me, I've tried running those commands time and time again but nothing ever worked... at some point I think I just gave up trying to make it work, most likely a conflict between VS and High Sierra. Thing is I can't upgrade my OS any further, so I'll have to stick with this setup for the time being. – yungfox May 17 '22 at 16:52
0

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

Amir Magdy
  • 188
  • 9