【发布时间】:2019-01-30 19:06:45
【问题描述】:
我正在按照 IdentityServer4 的快速入门指南设置受保护的 API 并使用客户端 (Sample 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 templates for web applications 的默认证书,我认为问题与证书是自签名的事实有关。这是正确的吗?
信任另一个容器中的自签名证书以便建立连接的正确方法是什么?
【问题讨论】:
-
将您的自签名证书添加到其他 docker 中的信任库(@see B.3 docs.jboss.org/teiid/7.1.0.Final/client-developers-guide/en-US/…)
-
但是如何在 Docker 和 .net 核心中做到这一点。我没有使用 Java。
-
这里可以找到对应的powershell命令列表:blogs.msdn.microsoft.com/zxue/2016/12/19/…
标签: docker ssl asp.net-core identityserver4