gpt4 book ai didi

azure - 将根 CA 添加到 Azure 应用服务以进行客户端证书身份验证

转载 作者:行者123 更新时间:2023-12-02 23:24:50 25 4
gpt4 key购买 nike

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

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

谢谢!

最佳答案

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 应用程序。

关于azure - 将根 CA 添加到 Azure 应用服务以进行客户端证书身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64936459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com