asp.netcore3.1 将服务器配置为需要证书

运行 asp.netcore 3.1应用程序时,弹出证书选择框。

将服务器配置为需要证书(Kestrel)Program.cs中,按如下所示配置 Kestrel:

public static void Main(string[] args)
{
    CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args)
{
    return Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
            webBuilder.ConfigureKestrel(o =>
            {
                o.ConfigureHttpsDefaults(o => 
            o.ClientCertificateMode = 
                ClientCertificateMode.RequireCertificate);
            });
        });
}

参考官网:https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/certauth?view=aspnetcore-3.1#configure-your-server-to-require-certificates

 

posted @ 2020-06-15 18:14  FrankFyy  阅读(581)  评论(0编辑  收藏  举报