@@ -459,6 +459,57 @@ new Client
459459}
460460```
461461
462+ #### Configuring IdentityServer to Accept Client Certificates
463+
464+ When configuring mTLS in IdentityServer, you can specify to only expose the mTLS endpoints on a specific domain or subdomain:
465+
466+ ``` csharp {7}
467+ // Program.cs
468+ var idsvrBuilder = builder .Services .AddIdentityServer (options =>
469+ {
470+ options .MutualTls .Enabled = true ;
471+
472+ // Only exposes the MTLS endpoints on the mtls subdomain of your IdentityServer host.
473+ options .DomainName = " mtls" ;
474+ });
475+ ```
476+
477+ Specifying this domain name however triggers an additional authentication step in the [ MutualTlsEndpointMiddleware] [ 1 ] ,
478+ calling ` httpContext.AuthenticateAsync() ` with the configured client certificate authentication scheme name.
479+ By default, this scheme name is ` "Certificate" ` , but you can override this when configuring the mTLS options:
480+
481+ ``` csharp {6}
482+ // Program.cs
483+ var idsvrBuilder = builder .Services .AddIdentityServer (options =>
484+ {
485+ options .MutualTls .Enabled = true ;
486+ options .DomainName = " mtls" ;
487+ options .ClientCertificateAuthenticationScheme = " Certificate" ;
488+ });
489+ ```
490+
491+ In addition, you need to also configure client certificate authentication in ASP.NET Core:
492+
493+ ``` csharp {9-16}
494+ // Program.cs
495+ var idsvrBuilder = builder .Services .AddIdentityServer (options =>
496+ {
497+ options .MutualTls .Enabled = true ;
498+ options .DomainName = " mtls" ;
499+ options .ClientCertificateAuthenticationScheme = " Certificate" ;
500+ });
501+
502+ builder .Services .AddAuthentication ()
503+ .AddCertificate (" Certificate" , options =>
504+ {
505+ // Specify which types of certificates to allow: SelfSigned, Chained, or All
506+ options .AllowedCertificateTypes = CertificateTypes .SelfSigned ;
507+ options .ValidateCertificateUse = true ;
508+ });
509+ ```
510+
511+ Further documentation on how to configure client certificate authentication in ASP.NET Core is available on [ Microsoft Learn] [ 2 ]
512+
462513### .NET Client Library
463514
464515When writing a client to connect to IdentityServer, the ` SocketsHttpHandler ` (or ` HttpClientHandler ` depending on your
@@ -496,3 +547,6 @@ static async Task<TokenResponse> RequestTokenAsync()
496547 return response ;
497548}
498549```
550+
551+ [ 1 ] : https://github.com/DuendeSoftware/products/blob/main/identity-server/src/IdentityServer/Hosting/MutualTlsEndpointMiddleware.cs#L155-L170
552+ [ 2 ] : https://learn.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-9.0
0 commit comments