【发布时间】:2020-09-11 19:01:07
【问题描述】:
我正在尝试将 Docker 用于现有应用程序,但遇到以下问题。当 API 尝试从容器中获取 Identity Server 元数据时,它会失败并显示以下内容:
web_api | System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://host.docker.internal:5500/.well-known/openid-configuration'.
web_api | ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://host.docker.internal:5500/.well-known/openid-configuration'.
web_api | ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
web_api | ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
主机浏览器确实确认了这一点(Chrome中的验证错误)。
如果我使用 localhost 而不是 host.docker.internal 访问相同的元数据,它会按预期工作。
我已使用来自here 的说明来创建并信任身份服务器也使用它的本地主机证书:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p { password here }
dotnet dev-certs https --trust
我假设这些说明仅为 localhost 创建证书,但我正在尝试获得一个也适用于 host.docker.internal 的解决方案。
问题:如何允许从本地主机和容器到 ASP.NET Core Web API 应用程序的 HTTPS 连接?
【问题讨论】:
标签: docker asp.net-core https ssl-certificate