I am trying to call an external service from my .net 8 service and facing the below error
System.Net.Http.HttpRequestException: The SSL connection could not be
established, see inner exception. —>
System.Security.Authentication.AuthenticationException: The remote
certificate is invalid because of errors in the certificate chain:
UntrustedRoot
I tried copying the cert I received from the vendor to different paths in my dockerfile as below:
###### Stage 1 - Restore, build, publish #################
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS builder
WORKDIR /app
#### Install Certs
RUN apt-get -y update
RUN apt-get install -yqq wget curl ca-certificates sed
COPY MyCert.cer /usr/local/share/ca-certificates/aspnet/MyCert.cer
RUN chmod 644 /usr/local/share/ca-certificates/aspnet/MyCert.cer && update-ca-certificates
COPY MyCert.cer /etc/ssl/certs/MyCert.cer
...
I also tried using the path /usr/local/share/ca-certificates/ but to no avail.
In my workflow to build image, I have to use the secret with the cer content to create a .cer file as below:
- name: Save My Cert to file
run: |
echo $MY_CERT > MyCert.cer
env:
MY_CERT : ${{ secrets.MY_CERT }}
I also tried adding my cert to the app service but that didn’t fix my problem either.
Can anyone please advise what I may be missing here to address the ssl connection error?