How to install Windows SSL certificates into your Docker Linux container
When using web applications inside a Docker Container you might come across SSL certificates that have to be installed on the running Container. Things get a little bit more complicated when you want to install Windows certificates into a Linux Image. Following you can see the steps to achieve this task.
Convert the Windows certificate into its Linux equivalent
Windows support the DER encoded certificates (.cer file ending) and you want to convert this certificate into a base-64 encoded one (.crt file ending), so that it can be read from Linux.
The tool I use for this operation is called openSSL for Windows. Install it on your Windows machine, make sure openSSL is added on the PATH of your Windows, navigate to the folder where the certificate can be found and run the following command in your command prompt:
openssl x509 -inform DER -in certificate.cer -out certificate.crt
Install the new certificate in your Container via Dockerfile
COPY certificate.crt /usr/local/share/ca-certificates/certificate.crt RUN chmod 644 /usr/local/share/ca-certificates/certificate.crt RUN update-ca-certificates
Pay special attention in the path we copy the certificate to (/usr/local/share/ca-certificates/). We also have to change the access rights of the file and lastly we install the certificate.