简体   繁体   中英

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?

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.

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.

The exception when I make a standard http client request:

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.

The code i'm running to copy and install the docker cert:

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

You also need to add the root certificate onto the system accessing the site, because you are using a self signed certificate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM