Click here to Skip to main content
15,665,276 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:

I am able to containerize .net core application with self signed certificate and able to connect to the one of the controller using https.

Below is the docker file.

FROM AS runtime

COPY published ./
COPY Test.WebApi.pfx ./

ENV ASPNETCORE_URLS="https://+:443;http://+:80"
ENV ASPNETCORE_Kestrel__Certificates__Default__Password="crypticpassword"
ENV ASPNETCORE_Kestrel__Certificates__Default__Path="./Test.WebApi.pfx"

ENTRYPOINT ["dotnet", "Test.WebApi.dll"]

Note: published folder has the .net core app published version. connecting to the controller using https is working fine as expected on docker. But when am invoking using httpclient from code is throwing below error.

Exception:The SSL connection could not be established, see inner exception. &
System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

In my local code is working fine. I mean code is able to connect to using httpclient and getting the response. But the same code is not throwing above exception on docker.

Generating image using below command
docker build -t config .

Running the image using below command
docker run -d -p 6000:80 -p 6001:443 config

NOTE: I am generating linux container image with .NET CORE application and used self singed certificate .pfx file.

Question: Why am unable to connect from my container image?

Posting for the first time so apologies if any mistakes.

What I have tried:

I have tried with setting up environment and volumes in docker file instead of during the container creation. As i want everything to be in docker file.
Updated 9-Sep-21 22:25pm

1 solution

Google for "Docker container has no internet" and start reading. There's a bunch of things it can be, and you're going to have to do the work of troubleshooting. Nobody can do it for you.
Share this answer
Varun@vin 9-Sep-21 16:26pm    
If you don't know the answer keep quiet and mind your own business. And FYI, container has internet. 😡
Dave Kreskowiak 9-Sep-21 16:38pm    
There's a ton of things that may be wrong. Guessing at which one, or more of them, it may be, takes some probing work on YOUR part to figure out what it is.

Wow. A wee arrogant are you? You're on your own now because of it.

Have a nice life.
Varun@vin 9-Sep-21 16:46pm    
Do you think people post without googling. So funny answer from you.
Dave Kreskowiak 9-Sep-21 16:47pm    
Yes, it happens most of the time.
Varun@vin 9-Sep-21 16:50pm    
Don't underestimate everyone, Anyway I can't waste my time. Thanks for your answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900