我正在按照IdentityServer4的快速入门指南设置受保护的API并使用客户端(示例2)进行访问。我正在使用.Net Core + Docker for Windows(Windows容器)运行我的测试应用程序。
设置应该类似于以下内容:
当我调用https://<identity-url>/.well-known/openid-configuration
时,我可以获取配置信息,但是会先出现已知的“不安全 - 是否确定”的页面。
API 1
受到以下保护:services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://<identity-url>";
options.RequireHttpsMetadata = this.Environment.IsProduction();
options.ApiName = "api1";
});
我会尽力为您翻译。下面是需要翻译的内容:
并且Config.cs
(在IdentityServer
) 是根据快速入门文档编写的。
问题:
当我尝试从我的Client
调用API 1
时,按照快速入门文档的要求,我需要首先访问IdentityServer
:
var disco = await DiscoveryClient.GetAsync("https://<identity-url>");
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return BadRequest(disco.Exception);
}
这导致了以下错误
根据验证程序,远程证书无效。
我正在使用.net core web应用程序模板
中的默认证书,我认为问题与证书是自签名有关。这个正确吗?
如何正确地信任另一个容器中的自签名证书,以建立连接?