How to Install Trusted Root Certificates in DotNet Core on Ubuntu
💻 coding

How to Install Trusted Root Certificates in DotNet Core on Ubuntu

1 min read 161 words
1 min read
ShareWhatsAppPost on X
  • 1To resolve SSL errors in .NET Core on Ubuntu, install self-maintained root certificates in the Docker container.
  • 2Copy the certificate .crt file to /usr/local/share/ca-certificates/ for it to be recognized by OpenSSL.
  • 3Run the command 'update-ca-certificates' in the Dockerfile to update the trusted certificates list.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"To resolve SSL errors in .NET Core on Ubuntu, install self-maintained root certificates in the Docker container."

How to Install Trusted Root Certificates in DotNet Core on Ubuntu

Question :

I'm getting an issue while deploying a .net-core web-API to a Docker container on Ubuntu. Everything works as expected, but from my application, I need to call other services via https and those hosts use certificates signed by self-maintained root certificates.

In this scenario, I get SSL-errors while calling this services (SSL-not valid) and therefore I need to install this root-certificate in the docker-container or somehow use the root-certificate in the .net-core application.

How can this be done? Is there a best practice to handle this situation? Will .net-core access the right keystore on the Ubuntu?

Solution:

Since .NET Core uses OpenSSL on Linux, you need to set up your Linux environment in the container so that OpenSSL will pick up the certificate.

This is done by (+ Dockerfile examples):

Copying the the certificate .crt file to a location that update-ca-certificates will scan for trusted certificates - e.g. /usr/local/share/ca-certificates/ oron RHEL /etc/pki/ca-trust/source/anchors/:

COPY myca.crt /usr/local/share/ca-certificates/

Invoking update-ca-certificates:

RUN update-ca-certificates

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 23 November 2018 · 1 min read · 161 words

Part of AskGif Blog · coding

You might also like

How to Install Trusted Root Certificates in DotNet Core on Ubuntu | AskGif Blog