【问题标题】:Azure Net core : The specified CGI application encountered an error and the server terminated the processAzure Net core:指定的 CGI 应用程序遇到错误,服务器终止了进程
【发布时间】:2019-01-21 17:03:47
【问题描述】:

我在 azure 中部署了我的 .net 核心应用程序。部署后,我有时会遇到这个问题“指定的 CGI 应用程序遇到错误,服务器终止了进程。”

在本地调试时工作正常。请帮我解决这个问题。

【问题讨论】:

  • 您是否使用了在您的 Azure 环境中可能不可用的任何外部库?或者像GDI这样的东西?请提供更多信息,因为这不足以帮助您。看看如何提供minimal reproducible example
  • 使用IdentityServer4,我生成了Token并刷新了token。刷新令牌功能发生错误。这个错误在azure环境中经常出现。在本地,它工作正常。没事吧??

标签: azure .net-core identityserver4


【解决方案1】:

在 Github 上查看 this issue。显然,当您尝试获取 IdentityServer 找不到的特定证书时,可能会发生这种情况。

我认为我未能检索到证书,这导致在需要时突然停止。

请看一下(有点过时的)文章Using Certificates in Azure Websites Applications

简而言之:

  1. 上传证书(例如上传到Azure Portal
  2. 添加应用设置
    添加名为 WEBSITE_LOAD_CERTIFICATES 的应用设置,并将其值设置为证书的指纹,这样您的 Web 应用程序就可以访问它。
  3. 访问证书:
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
                           X509FindType.FindByThumbprint,
                           “<YOUR_CERT_THUMBPRINT_HERE>”,
                           false);
// Get the first cert with the thumbprint
if (certCollection.Count > 0)
{
  X509Certificate2 cert = certCollection[0];
  // Use certificate
}

【讨论】:

    猜你喜欢
    • 2018-12-24
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    相关资源
    最近更新 更多