The usage of HTTPS is becoming more and more common these days—not only is the performance penalty that existed in the early days now gone, but it is also significantly cheaper to get a certificate; in some cases, it may even be free—for example, Let's Encrypt (https://letsencrypt.org) offers such certificates. Plus, search engines such as Google boost results for sites served through HTTPS. Of course, ASP.NET Core fully supports HTTPS. We will now see how to add certificates so that we can serve our sites using HTTPS, and how to restrict access to HTTPS only.
Let's begin with certificates.
Certificates
In order to use HTTPS, we need a valid certificate—one that browsers accept as valid. We can either acquire one from a root certificate provider or we can generate one, for development purposes. This won't be recognized as coming from a trusted source.
In order to generate a certificate and install...