Docker WebApi RemoteCertificateChainError RRS feed

  • Question

  • User-544325736 posted

    Hello all,

    I have 2 .net core projects that work perfectly with each other when I run them normal, I have an API and a MVC UI. When I run them in docker containers, I go on my API with swagger, I figured out how to connect my postgres db and insert data successfully. When I go on my UI and I call the API I get this error:

    An unhandled exception occurred while processing the request

    AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemotecertificateChainErrors.

    I created a certificate and have it in my .net project. I am guessing I have to do something different to make this work with a container. (If this is what is wrong, I’m not sure yet.)

    To put it in my normal project I did this.

    .UseKestrel(serverOptions =>
                            serverOptions.Listen(IPAddress.Loopback, 5010);
                            serverOptions.Listen(IPAddress.Loopback, 5011, listenOptions =>
                                listenOptions.UseHttps("localpfx.pfx", "password");

    I have a Dockerfile in my .net core project. I am not using docker compose.

    Any ideas how to get my UI to call my API both running in separate containers? This is the last part of my project.

    Thank you.

    Wednesday, February 24, 2021 2:54 PM


  • User-474980206 posted

    You need to do two things

    1. In api project, the cert file needs to assessable from the asp.net core project, either by copying into the docker container or via a mount (more common)
    2. in the UI project, the cert needs to be installed as a trusted cert. this will depend on the docker o/s you picked. Google for instructions.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 24, 2021 3:49 PM