I have the following code:
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("https://*:" + port)
.Configure(Configure)
.Build();
which works wonderfully on windows – I can access it with https://127.0.0.1:1111 and it works fine. When I try it on a mac – it runs, but when I try and connect to it, it immediately just goes “connection closed”
I googled and found that in usekestrel, you should be able to add
.UseKestrel( options => options.UseHttps...
which is documented here:
however when I try it, I’m only finding .UseSystemd as an option – no .useHttps – even though I’m referencing Microsoft.AspNetCore.Server.Kestrel.Https.
What am I doing wrong? Why does it behave differently on mac vs windows, and how do I fix it so that it also works on the mac?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
so for anyone who runs across this – I found I guess an answer:
you need to run in the terminal:
dotnet dev-certs https
which then asks you to run a really bizarre command:
sudo security set-key-partition-list -D localhost ...
which magically fixes things.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0