I am running a ASP.NET Core container. This container sends a request to an api that is ssl encrypted by a self signed certificate. I need my container to trust the certificate, so that the request goes through. The Container is using microsoft/dotnet:2.1-aspnetcore-runtime as base so it is using ubuntu.
I have tried the following:
I exported the certificate on the server that holds the api and created a .crt with openssl by using the following command:
openssl pkcs12 -in exportedcert.pfx -clcerts -nokeys -out my.crt
Then I added the following to my Dockerfile:
ADD /my.crt /usr/local/share/ca-certificates/my.crt
RUN chmod 644 /usr/local/share/ca-certificates/my.crt && update-ca-certificates
The image builded perfectly but my application still throws: "AuthenticationException: The remote certificate is invalid according to the validation procedure."
Afterwards I tried adding this to the Dockerfile:
RUN apt-get update && apt-get install -y ca-certificates
COPY /my.crt /usr/local/share/ca-certificates/my.crt
RUN update-ca-certificates
The same error occured.
Does anyone know how I can add the certificate to the CA, so that the container trusts it? Did I create the certificate for the container in the wrong way? Any help is greatly appreciated.