我托管了一个身份服务器,它在一个我的天蓝色VM中使用IIS中的自签名证书。这是ssl启用的网站。这是使用identityserver3框架。
我在同一个虚拟机中托管asp.net core 2.0 webapi,这不是ssl启用的。 以下是我在核心2.0 api方面的设置:
Startup.cs -> ConfigurationServices() {
services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://localhost:44300/identity";
options.RequireHttpsMetadata = false;
options.ApiName = "web_api";
options.LegacyAudienceValidation = true;
});
}
通过上述设置,两者都在本地工作正常。但是在我尝试访问api的vm中,我收到了以下错误:
ERROR Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler - Exception occurred while processing message. - System.InvalidOperationException: IDX10803: Unable to obtain configuration from: 'https://localhost:44300/identity/.well-known/openid-configuration'. ---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'https://localhost:44300/identity/.well-known/openid-configuration'. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A security error occurred
我确保
中提供了自签名证书MMC->在当前用户和本地计算机中对证书进行了认证。
自签名证书可在以下网址获得:
MMC->本地计算机 - >个人证书 本地计算机 - >受信任的根证书
MMC - >当前用户 - >受信任的根证书
答案 0 :(得分:1)
出现同样的问题,直到我发现托管IdentityServer的运行应用程序池的用户至少应该拥有对证书的读取权限。
MMC - >当前用户 - >受信任的根证书
这是您的帐户权利,但请检查哪个是应用程序池帐户,然后在计算机证书中:
右键单击证书 - >所有任务 - >管理私钥
同时意识到,无法向DefaultAppPoolIdentity
授予此类权限,因此我最终为此应用池使用了单独的帐户。