【发布时间】: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