gpt4 book ai didi

azure - 我应该将 Azure 应用程序注册证书放置在本地服务器上的哪个证书存储中

转载 作者:行者123 更新时间:2023-12-03 06:57:24 25 4
gpt4 key购买 nike

我已经为我们正在开发的 .NET 6 应用程序设置了 Azure KeyVault。

我按照此处的说明进行操作 - https://learn.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-6.0#use-application-id-and-x509-certificate-for-non-azure-hosted-apps

它基本上包括;

  • 创建证书
  • 将证书安装到您的个人用户存储中
  • 将其添加到相关的 Azure 应用注册
  • 添加访问策略
  • 将以下代码添加到应用中
using var x509Store = new X509Store(StoreLocation.CurrentUser);
x509Store.Open(OpenFlags.ReadOnly);
var x509Certificate = x509Store.Certificates
.Find(
X509FindType.FindByThumbprint,
builder.Configuration.GetSection("AzureAd")["CertificateThumbprint"],
validOnly: false)
.OfType<X509Certificate2>()
.Single();


builder.Configuration.AddAzureKeyVault(
new Uri($"https://{builder.Configuration.GetSection("KeyVault")["Name"]}.vault.azure.net/"),
new ClientCertificateCredential(
builder.Configuration.GetSection("AzureAd")["DirectoryId"],
builder.Configuration.GetSection("AzureAd")["ApplicationId"],
x509Certificate));

在本地运行时效果非常好。我现在的问题是我需要将其部署到运行 IIS 的本地服务器。

这一行

using var x509Store = new X509Store(StoreLocation.CurrentUser);

告诉它搜索“当前用户”证书存储。在本地运行时这很好,因为那是我,但在服务器上运行时,特别是带有 IIS 10 的 Windows Server 2019,那是谁,这是否是正确的做法。

我的问题归结为两件事。

1 - 如果我按原样使用此代码,那么在服务器上运行时谁是“CurrentUser”。我假设它是 ApplicationPoolIdentity 用户 (IISAppPool/NameOfPool)。如果是这样,我如何向他们的商店添加证书?

2 - 或者,我假设我可以将 StoreLocation.CurrentUser 更改为 StoreLocation.LocalMachine,并将证书安装到本地计算机。这应该可行,但是有缺点吗?

最佳答案

只要证书不可导出,将存储设置为 LocalMachine 就可以了。

关于azure - 我应该将 Azure 应用程序注册证书放置在本地服务器上的哪个证书存储中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72787666/

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