Andrzej Osowski
Andrzej Osowski

Reputation: 43

Integration Testing Issue with .NET API Gateway (Ocelot) in Docker using HTTPS and Self-Signed Certificates: 'PartialChain' Error

I'm trying to write integration tests for my .NET 8 API gateway (Ocelot). I chose to use docker containers orchestrated by docker-compose. Redirections work perfectly when tests are run against http but once I tried to test against https, I just hit a wall. I want to have one ocelot configuration file, to not repeat configuration just for testing popruses. I'm using self-signed certificates but I keep getting an error when requesting https URL:

The remote certificate is invalid because of errors in the certificate chain: PartialChain

I get this error only on my gateway container. The target service container is not logging anything, so I assume that my request doesn't reach it. I've confirmed that the certificates are signed by my local rootCA. I don't see any issues in my dockerfiles either.

Here is the part of my dockerfile where I set up the certificates:

COPY api-gateway/XXX-api-gateway/apigateway.pfx /https/
COPY ./rootCA.crt /usr/local/share/ca-certificates/rootCA.crt
RUN chmod 644 /usr/local/share/ca-certificates/rootCA.crt && update-ca-certificates

ENV ASPNETCORE_ENVIRONMENT=Development
ENV ASPNETCORE_URLS="http://*:6000;https://*:6001"
ENV ASPNETCORE_KESTREL__ENABLE_HTTPS=true
ENV ASPNETCORE_KESTREL__HTTPS_PORT=6001
ENV ASPNETCORE_KESTREL__HTTPS_REDIRECT_PORT=6001
ENV ASPNETCORE_KESTREL__HTTPS_DEFAULT_SCHEME=https
ENV ASPNETCORE_Kestrel__Certificates__Default__Password "Password123!"
ENV ASPNETCORE_Kestrel__Certificates__Default__Path "/https/apigateway.pfx"

What might be the issue? Or maybe this is just not a good way of making integration tests?

Upvotes: 0

Views: 80

Answers (0)

Related Questions