Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL in Asp.Net Core doesn't work

I created a simple web application from visual studio Web Application(Net.Core) template with individual user account authorization.

Then, I enabled SSL in Project->MyProject Properties..., copied URL with https to App Url.

Finally, I added:

services.AddMvc(options =>
{
    options.Filters.Add(new RequireHttpsAttribute());
});

to Startup.

And it doesn't work! When I'm starting the application, it just simply turns off after a second, and nothing happens, no error, nothing!

What's wrong with SSL in Asp.Net Core, and how can I enable it correctly?

like image 834
Yurii N. Avatar asked Oct 12 '16 10:10

Yurii N.


Video Answer


1 Answers

For development testing you need to enable SSL first.

Right click the project > Properties > Debug

  • Choose "IIS Express" in profile
  • Check "Enable SSL"

If your debugging stops after starting (no process ID found), then you have to install the IIS Express self-signed certificate into the certificate store.

You can follow this guide here. It's bit older but still applies to Visual Studio 2015. It's due to a bug in Update 3 where IIS Certificate isn't installed in the trusted certificate storage correctly.

Alternatively,

  1. hit Win+R, type run "mmc.exe"
  2. File > Add Snap-in > Choose "Certificates" > Add > Computer Account > Next > Finish
  3. Hit OK
  4. Go to "Personal/Certificates". Look for "localhost" Zertificate
  5. Drag & Drop the certificate to "Trusted Root Certification Authorities"
  6. Close the MMC. Restart Visual Studio 2015

Now you should be able to debug it.

like image 170
Tseng Avatar answered Nov 15 '22 04:11

Tseng