从 ASP.NET 核心读取 Azure 默认通配符证书

Read Azure default wildcard certificate from ASP.NET Core

我正在 Azure 应用服务中建立暂存环境。它位于免费套餐下,您无法在其中上传自定义 SSL 证书。为了测试我的 ASP.NET 核心应用程序设置,特别是它是否可以正确地从商店加载证书,我想尝试一下,而不必满足对受信任证书的所有要求(更改层、获取域、获得证书,...)。

我知道 Let's Encrypt,但这仍然会迫使我切换层以将证书添加到 Azure 应用服务。另外,我不确定您是否可以为域 some-site.azurewebsites.net 创建证书(我在某处读过一些反对使用与 azurewebsites.net 相关的内容作为自定义证书的内容),所以也许这还需要一个自定义域。

我想知道是否有办法从应用程序代码访问 MS 为 *.azurewebsites.net 拥有的默认通配符证书。所以像抓取 MS Azure 证书指纹,将其存储在 WEBSITE_LOAD_CERTIFICATES 应用程序设置中,然后从商店加载它完成 here in chapter 3. Access from app"

X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);

X509Certificate2Collection certCollection = certStore.Certificates.Find(
   X509FindType.FindByThumbprint,
   "insert-here-thumbprint-of-azure-default-cert",
   false);

// Get the first cert with the thumbprint
if (certCollection.Count > 0)
{
  X509Certificate2 cert = certCollection[0];
  // Use certificate
  Console.WriteLine(cert.FriendlyName);
}

certStore.Close();

这可行吗? TA.

显然, 有答案。它的要点是:

You will not be able to access this certificate programmatically in your WebApp as this certificate is not really installed on the Azure WebApp.

不确定是否应将其作为重复项关闭。