Using your own SSL Certificate

Modified on: Tue, 20 Dec, 2022 at 1:26 PM

Many customers would like to replace our server certificates with their own certificates issued with the correct common name and using their company or commercial Certificate Authority (CA).

There are two methods of achieving this which are both explained below.

The paths for the files that you need to overwrite are as defined in /etc/nginx/conf.d/dispatcher.conf  within the ctasnginx docker container:

  1. /etc/nginx/server.crt
  2. /etc/nginx/server.key

You should be able to overwrite the above files in the Docker containers in order to change the certificate that is being used, however, by changing the files inside the Docker container, you will need to repeat this action every time the Docker images change when an update is released because the changes will be lost every time a new container is created.

There is a long-term solution though; ideally we would like to make use of the Docker workflow to change the certificates but also achieve additional objectives:

  1. Document what changes we are making to the Docker containers
  2. Have the changes persist between updates

Building a custom Docker image that is based on our original image will allow us to achieve this. The following example will demonstrate the changes required for the CTAS server. The example will assume that you are in a directory containing the following files:

  1. Dockerfile: new Dockerfile created
  2. ctas-custom.yml: additional docker-compose file to customize docker setup
  3. server_cert.crt: crt file for the new certificate
  4. server_cert.key: key file for the new certificate

Prepare new certificate

Prepare a new certificate as per the requirements of your organization.

Note: NGINX recommends that the full certificate chain is in the certificate file. Be sure to create a combined certificate with any intermediate certificates, e.g.: cat main.crt intermediate.crt > combined.crt

First we need to build a new Docker image that is based off of our image and contains the custom certificate and its key.

We can do this by creating the following Dockerfile:

USER root
COPY server_cert.crt /etc/nginx/server.crt
COPY server_cert.key /etc/nginx/server.key
RUN chown -R webserver:webserver /etc/nginx/server.*
USER webserver

This will create a new Docker image that is based off our server image, but has new certificate and its key copied from a local directory into the container.

Next we need to change our Docker-compose file to reference the local Dockerfile, rather than using our images directly. We will make changes to our compose file, whilst following the guidelines outlined here.

We can create a new Docker-compose file with the filename “ctas-custom.yml”. The file should have the following contents:

version: '3'
    build: .

The above contents tells Docker to build an image using the Dockerfile from the local directory, rather than running our image directly.

We can then run the server using our new certificate with the command:

docker-compose -f mst_onprem.yml -f ctas-custom.yml up -d --build

This will build and start a new server using your certificate and its key for HTTPS connections.

Method 2: Temporary Solution

If rebuilding containers won’t be an option for you, you can replace the SSL certificates inside the container.

Warning: This is a temporary solution that won’t survive an update. You need to repeat these instructions in the future.

Log into the Server or VM that hosts the CTAS Docker Containers.

Log into the CTAS container terminal

Start by obtaining the Container ID or Container Name.

docker ps

Sample output:

0afddd35cdf3 ... maltego_ctastransforms_1
8cb065694455 ... maltego_ctasnginx_1
c5a7dd3d6b85 postgres:10

Identify the ‘CONTAINER ID’ for the ‘ctasnginx’ instance, and use the ‘exec’ argument with ‘docker’ to log into the system.

Replace ID with the one from your instance:

sudo docker exec -it 8cb065694455 bash

Sample output:


Find the pre-installed SSL certificates:

cd /etc/nginx/

Sample output:

-rw-r--r-- 1 root root 1724 Oct 19 2018 CA.crt
-rw-r--r-- 1 root root 1196 Oct 19 2018 server.crt
-rw-r--r-- 1 root root 1704 Oct 19 2018 server.key

Rename the “server.crt” and “server.key” files to backups.

mv server.crt server.crt.bck
mv server.key server.key.bck

Sample output:

-rw-r--r-- 1 root root 1724 Oct 19 2018 CA.crt
-rw-r--r-- 1 root root 1196 Oct 19 2018 server.crt.bck
-rw-r--r-- 1 root root 1704 Oct 19 2018 server.key.bck

Exit the CTAS container terminal:


Copy the new SSL certificates to the CTAS container

Use the same Docker Container ID or Container Name used previously to log into the CTAS container to copy the new certificates into the container.

sudo docker cp internal_cert.crt 8cb065694455:/etc/nginx/server.crt
sudo docker cp internal_cert.key 8cb065694455:/etc/nginx/server.key

Restart the CTAS Container.

Use the same Docker Container ID or Container Name used previously to log into the CTAS  container.

sudo docker restart 8cb065694455

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.