【问题标题】:Azure web app "Couldn't find a valid certificate"Azure Web 应用“找不到有效的证书”
【发布时间】:2021-01-28 13:22:18
【问题描述】:

所以我创建了一个带有 IdentityServer 身份验证的 ASP.NET Core 网站并将其发布到我的 Azure Web 应用程序,但它抱怨证书。我只是使用没有自定义域的默认基本 1 层 Web 应用程序。 Web 应用程序由开箱即用的证书签名,所以我不能以某种方式使用它吗?

我真的需要购买自定义域和我自己的证书才能使用吗?如果我可以在没有自定义域的情况下继续使用网络应用程序,我会更喜欢。

在诊断转储中我可以看到错误

   Couldn't find a valid certificate with subject 'CN=MyApplication' on the 'CurrentUser\My'
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.SigningKeysLoader.LoadFromStoreCert(String subject, String storeName, StoreLocation storeLocation, DateTimeOffset currentTime)
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.LoadKey()
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.Configure(ApiAuthorizationOptions options)

Startup.cs

        var identityserver = services.AddIdentityServer();
        identityserver.AddApiAuthorization<ApplicationUser, AutheticationDbContext>();
        identityserver.AddSigningCredentials();

        services.AddAuthentication()
            .AddIdentityServerJwt();

appSettings.json

  "IdentityServer": {
    "Clients": {
      "MyWebProjectName.Client": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "Store",
      "StoreName": "My",
      "StoreLocation": "CurrentUser",
      "Name": "CN=MyApplication"
    }
  }

【问题讨论】:

  • “网络应用程序由开箱即用的证书签名,所以我不能以某种方式使用它吗?” -> 不,因为对于应用服务,SSL 终止发生在请求甚至到达您的应用之前
  • 我的回答应该对你有用。使用 webapp 的默认域名并创建自签名证书是可行的。如果您有任何问题,请告诉我。

标签: azure asp.net-core azure-web-app-service


【解决方案1】:

当你部署你的 webapp 时,你会得到一个类似的 url:https://appname.azurewebsites.net

我真的需要购买自定义域和我自己的证书才能使用吗?

然后就可以使用powershell生成self signed certificate了。因此您无需创建新域或购买证书。

部署应用程序后,您还需要在门户上上传您的自签名证书,例如 Syarif Mathis 在下面帖子中的回答。

How to configure key settings for IdentityServer in appsettings.json for aspnet core app running on IIS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多