gpt4 book ai didi

docker - IdentityServer4 + Docker : The remote certificate is invalid according to the validation procedure

转载 作者:太空宇宙 更新时间:2023-11-03 14:31:57 26 4
gpt4 key购买 nike

我正在按照 IdentityServer4 的快速入门指南设置 protected API 并使用客户端访问它 (Sample 2)。我正在使用 .Net Core + Docker for Windows(Windows 容器)来运行我的测试应用程序。

设置应该是这样的:

enter image description here

当我调用 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 中)根据快速入门的文档。

问题:

当我尝试调用 API 1 时来 self 的 Client我需要访问 IdentityServer首先(根据快速入门):

var disco = await DiscoveryClient.GetAsync("https://<identity-url>");
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return BadRequest(disco.Exception);
}

这导致了这个错误

The remote certificate is invalid according to the validation procedure.

我正在使用 .net core templates for web applications 中的默认证书我认为问题与证书是自签名的事实有关。这是正确的吗?

信任其他容器中的自签名证书以便建立连接的正确方法是什么?

最佳答案

您可以为您的容器添加 de 证书,但这仅适用于外部请求,在容器之间您收到错误的证书 The remote certificate is invalid according to the validation procedure 因为这是不可能的验证证书,docker 网络是安全的,您可以覆盖策略以允许 http insted https

IdentityModel 有扩展方法 GetDiscoveryDocumentAsync 重载以添加策略以允许 http

    DiscoveryDocumentResponse disco = 
await client.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest {
Address = "http://<identity-url>",
Policy = { RequireHttps = false }
});

关于docker - IdentityServer4 + Docker : The remote certificate is invalid according to the validation procedure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52002117/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com