简体   繁体   English

Docker - 如何通过 SSL 连接到 host.docker.internal?

[英]Docker - How do you connect to host.docker.internal on SSL?

I'm quite new to Docker and I'm wondering how I can connect (httpclient get request) to a non-containerised application running on IIS that uses SSL (localhost) from a container?我对 Docker 很陌生,我想知道如何将(httpclient get 请求)连接到在 IIS 上运行的使用容器中的 SSL(本地主机)的非容器化应用程序?

The application i'm trying to connect to and the one i'm running in a container are both .NET Core and i'm using Visual Studio to debug this with it's container tools.我试图连接的应用程序和我在容器中运行的应用程序都是 .NET Core,我正在使用 Visual Studio 用它的容器工具调试它。

I have found the host.docker.internal allows me to connect to the non-containerised application on a http binding, but when I try to connect to the 443 version it gives me an exception that it doesn't trust the binding with little other information.我发现 host.docker.internal 允许我在 http 绑定上连接到非容器化应用程序,但是当我尝试连接到 443 版本时,它给了我一个例外,它不信任其他绑定信息。

The exception when I make a standard http client request:我发出标准 http 客户端请求时的异常:

The remote certificate is invalid according to the validation procedure.根据验证程序,远程证书无效。

I have tried installing localhost and host.docker.internal certificates created with OpenSSL onto the docker container i'm running from - with no success.我尝试将使用 OpenSSL 创建的 localhost 和 host.docker.internal 证书安装到我正在运行的 docker 容器上 - 但没有成功。

The code i'm running to copy and install the docker cert:我正在运行以复制和安装 docker 证书的代码:

WORKDIR /src
RUN apt-get update && apt-get install -y curl && apt-get install -y ca-certificates
COPY ./myLocal.crt /usr/local/share/ca-certificates/myLocal.crt
RUN update-ca-certificates

Am I missing a vital step to this?我错过了重要的一步吗? Thanks谢谢

Depending on the version of SSL, newer browsers may not accept TLS 1.1 for example and you are required to be using TLS 1.2例如,根据 SSL 的版本,较新的浏览器可能不接受 TLS 1.1,您需要使用 TLS 1.2

You also need to add the root certificate onto the system accessing the site, because you are using a self signed certificate.您还需要将根证书添加到访问该站点的系统上,因为您使用的是自签名证书。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker - host.docker.internal" (192.168.65.2) 拒绝连接 - Docker - host.docker.internal" (192.168.65.2) refused to connect 如何将域命名为“host.docker.internal”? - How to CNAME a domain to “host.docker.internal”? MYSQL:连接到本地主机和主机。docker.internal - MYSQL:Connect to both localhost & host.docker.internal host.docker.internal 主机上正在运行什么? - What is running on host.docker.internal host? 使用 host.docker.internal 从 docker 连接到本地机器(主机)中的 SQL Server - Connect to SQL Server in local machine (host) from docker using host.docker.internal 如何在启用自定义 dns 配置的情况下使 host.docker.internal 工作? - How do I make host.docker.internal work with custom dns configuration enabled? 什么是 linux 相当于“host.docker.internal” - What is linux equivalent of “host.docker.internal” 等效于 Rancher Desktop 中 Docker 桌面的 'host.docker.internal' - Equivalent to Docker Desktop's 'host.docker.internal' in Rancher Desktop 当容器需要连接宿主机时,为什么 localhost 必须替换为 host.docker.internal? - Why does localhost have to replaced with host.docker.internal when a container needs to connect to the host machine? 'dotnet ef database update' 命令给出错误:不允许主机 'host.docker.internal' 连接到此 MySQL 服务器 - 'dotnet ef database update' command gives error: Host 'host.docker.internal' is not allowed to connect to this MySQL server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM