I am using below code to add certificate in pod/container's certificate root store,
var cert = new X509Certificate2(Convert.FromBase64String(File.ReadAllText("/etc/secret/certfile")));
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(new X509Certificate2(cert));
store.Close();
But getting below error,
System.Security.Cryptography.CryptographicException: The X509 certificate could not be added to the store. ---> System.UnauthorizedAccessException: Access to the path '/.dotnet/corefx/cryptography/x509stores/root' is denied. ---> System.IO.IOException: Permission denied
I have below docker file which I am using,
FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine
RUN apk upgrade -U
EXPOSE 5000 7000
ENV ASPNETCORE_URLS=http://*:5000
WORKDIR /app
COPY . /app
USER guest
ENTRYPOINT ["dotnet", "Test.Web.dll"]