liveBook · Manning

Chapter 28: Adding HTTPS to an application

What you will learn in chapter 28 of ASP.NET Core in Action, 3e

This chapter introduces HTTPS as an essential protection for client-app traffic and previews local certificates, production Kestrel configuration, and application-wide HTTPS enforcement.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces HTTPS as an essential protection for client-app traffic and previews local certificates, production Kestrel configuration, and application-wide HTTPS enforcement.

Key terms: HTTPS, encryption, requests, responses, ASP.NET Core HTTPS development certificate, development certificate, production certificate, Kestrel, custom certificate, HTTP Strict Transport Security

28.1 Why do I need HTTPS?

This section explains why production applications need HTTPS and compares direct HTTPS handling in Kestrel with TLS offloading at a reverse proxy.

Key terms: HTTP, unencrypted, plain text, requests, responses, HTTPS, TLS, SSL, TLS certificate, Secure Sockets Layer

28.2 Using the ASP.NET Core HTTPS development certificates

This section explains how ASP.NET Core’s local HTTPS development certificates work, why browsers may reject them, and how to trust or troubleshoot them during development.

Key terms: HTTPS development certificate, .NET SDK, ASP.NET Core default templates, TLS certificate, public key, private key, certificate authority, CA, root certificate, dotnet dev-certs https --trust

28.3 Configuring Kestrel with a production HTTPS certificate

This section explains how to obtain and securely configure a production TLS certificate as Kestrel’s default HTTPS certificate, so an app can serve encrypted traffic outside development.

Key terms: TLS certificate, certificate authority, CA, domain ownership, trust process, Kestrel, development certificate, default certificate, Kestrel:Certificates:Default, .pfx

28.4 Enforcing HTTPS for your whole app

This section introduces why and how an ASP.NET Core application should enforce HTTPS, including browser behavior, reverse-proxy considerations, and the three approaches covered next.

Key terms: HTTPS, TLS, HTTP/2, HTTP/3, HTTP Strict Transport Security, HSTS, HTTPS redirection middleware, HTTP security headers, reverse proxy, SSL/TLS offloading

28.4.1 Enforcing HTTPS with HTTP Strict Transport Security headers

This section explains how HSTS headers make browsers prefer HTTPS after a secure visit, how to configure them safely in ASP.NET Core, and how HSTS preload removes the first-request gap.

Key terms: HTTP Strict Transport Security, HSTS, Strict-Transport-Security header, HTTPS, HstsMiddleware, MaxAge, HSTS header, Program.cs, HSTS preload, preload directive

28.4.2 Redirecting from HTTP to HTTPS with HTTPS redirection middleware

This section explains how HTTPS redirection middleware redirects insecure requests, how to configure it correctly behind a reverse proxy, and why it is paired with HSTS.

Key terms: HttpsRedirectionMiddleware, HTTPS redirection, HTTP 307 Temporary Redirect, short-circuits, HTTPS endpoint, UseHttpsRedirection, Program.cs, HstsMiddleware, ASPNETCORE_HTTPS_PORT, Kestrel

28.4.3 Rejecting HTTP requests in API applications

This section explains why API applications should disable HTTP entirely and serve only HTTPS requests.

Key terms: API application, HTTPS, HTTP, HSTS, HSTS preload, ASPNETCORE_URLS, https://, HTTP connections, port 5001, HTTPS redirection middleware

28.5 Summary

This summary recaps why production ASP.NET Core apps need HTTPS, how certificates can be provided in development and production, and how to enforce HTTPS-only access.

Where this is used later

Concepts explained in this chapter

← Chapter 27: Publishing and deploying your application Chapter 29: Improving your application’s security →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.