【问题标题】:Add Root CA to Azure App Service for Client Certificate Authentication将根 CA 添加到 Azure 应用服务以进行客户端证书身份验证
【发布时间】:2020-11-20 20:30:15
【问题描述】:

我正在构建一个依赖客户端证书进行身份验证的 Web 应用程序。尽管我必须将客户端证书的根 CA 添加到证书存储区,但我已经能够通过 IIS 在 Windows VM 上成功运行它。

当我想将同一个应用程序部署到 Azure 应用程序服务时,我似乎找不到做类似事情的地方。我错过了什么?

谢谢!

【问题讨论】:

    标签: azure azure-web-app-service client-certificates mutual-authentication


    【解决方案1】:

    cannot install custom root certificates for the App Service,但这不是必须的。

    Azure Web App 前端不进行任何证书验证。验证仅由用户代码处理。在 Asp.Net Core 中,您通常将验证卸载到 Microsoft.AspNetCore.Authentication.Certificate,它支持自定义证书。

    Asp.Net Core 5

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseAuthentication();
        
        // other items omitted
    }
    
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddAuthentication()
            .AddCertificate(options =>
            {
                options.ChainTrustValidationMode = X509ChainTrustMode.CustomRootTrust;
                options.CustomTrustStore = new X509Certificate2Collection(
                    new[]
                    {
                        new X509Certificate2(Convert.FromBase64String(myRootCertificate)),
                    });
            })
            
            // other items omitted
    }
    
    

    请注意,此设置支持自定义根证书。所有默认操作系统根证书都将被忽略。

    Asp.Net Core 6

    PR 29828介绍了一种添加链式证书的方式:

    public class CertificateAuthenticationOptions : AuthenticationSchemeOptions
    {
    
       /// <summary>
       /// Collection of X509 certificates which are added to the X509Chain.ChainPolicy.ExtraStore of the certificate chain.
       /// </summary>
       public X509Certificate2Collection AdditionalChainCertificates { get; set; } = new X509Certificate2Collection();
    
    }
    

    除了操作系统支持的证书(在本例中为 Azure Web 应用)之外,还将使用这些证书。

    【讨论】:

      【解决方案2】:

      很遗憾,无法将根证书添加到应用服务。

      更多细节可以参考这篇文章的答案。

      Adding trust to root certificate store on an App Service

      【讨论】:

        猜你喜欢
        • 2013-01-26
        • 1970-01-01
        • 1970-01-01
        • 2012-01-10
        • 2021-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-29
        相关资源
        最近更新 更多