IdentityServer4 Version="4.1.1" MTLS 配置 services.AddAuthentication().AddCertificate 不起作用

问题描述

Startup.cs 设置有问题,根据我应该添加的文档

services.AddAuthentication()
    .AddCertificate(options =>
    {
        options.AllowedCertificateTypes = CertificateTypes.All;
        options.RevocationMode = X509RevocationMode.NoCheck;
    });

但是我遇到了错误

'AuthenticationBuilder' 不包含定义 'AddCertificate' 并且没有扩展方法 'AddCertificate'。

在示例代码设置 IdentityServer(HOST)/ConsoleMTLSClient 中它有效。

解决方法

您必须添加 Microsoft.AspNetCore.Authentication.Certificate NuGet 包。