Course contentsShow
← C#
Lesson 1280 of 1,90811. Identity, Security, and ClaimsFree lesson

Ensuring Transport Layer Security

Force TLS 1.3 across all communication paths for authentication and authorization data.

In this lesson, you will learn how to enforce TLS 1.3 for all authentication and authorization traffic to ensure your identity data remains protected by the most modern cryptographic standards.

Why TLS 1.3 Matters for Identity

While previous versions of TLS relied on older, potentially vulnerable handshake mechanisms, TLS 1.3 removes support for outdated cryptographic algorithms and mandates a faster, more secure "1-RTT" handshake. When handling sensitive tokens, claims, and credentials, enforcing TLS 1.3 ensures that attackers cannot perform downgrade attacks to intercept your authentication traffic.

Enforcing Protocol Versions in ASP.NET Core

In C#, you control the transport layer behavior via the KestrelServerOptions. By explicitly setting the SslProtocols enum, you instruct your server to reject any connection attempts that do not meet your security requirements.

To force TLS 1.3 for your identity services, you configure the server within your Program.cs or Startup.cs file:

builder.WebHost.ConfigureKestrel(options =>
{
    options.ConfigureHttpsDefaults(httpsOptions =>
    {
        // Enforce TLS 1.3 specifically
        httpsOptions.SslProtocols = System.Security.Authentication.SslProtocols.Tls13;
    });
});

The Impact on Communication Paths

When you enforce Tls13 globally, your identity provider will strictly refuse connections from clients attempting to use TLS 1.0, 1.1, or 1.2. This is critical for authentication and authorization data because it prevents "Man-in-the-Middle" attacks where a malicious actor might try to force your server to negotiate a weaker protocol to decrypt your bearer tokens or session cookies.

Keep in mind that while this approach provides robust security, it does require that all internal services and third-party consumers interacting with your identity endpoints are also updated to support the TLS 1.3 specification. If a legacy internal service attempts to communicate with your hardened endpoint using an older protocol, the connection will fail immediately at the handshake level, preventing the transmission of unencrypted or weakly encrypted claims.

Key Takeaway: By explicitly restricting SslProtocols to Tls13 in your Kestrel configuration, you eliminate the risk of protocol downgrade attacks, ensuring your authentication traffic is always protected by the strongest available transport security.