Trusting AWS RDS Certificates in Docker and Beanstalk

To connect to AWS RDS databases using TLS/SSL, the client must trust the certificate provided by RDS; RDS doesn’t use certificates trusted by the CAs (Certificate Authorities) included by operating systems.

Without TLS/SSL, the connection to the database isn’t secure, meaning an attacker on the network between the client (running in EC2) and the database (running RDS) could eavesdrop or modify data.

To trust the AWS RDS certificate authority, on Docker, for a Red Hat / CentOS / Fedora / Amazon Linux (or other Fedora-type system) derived container, add the following to the Dockerfile:

set -e # stop on all errors
RUN curl "" --output /etc/pki/ca-trust/source/anchors/rds-combined-ca-us-gov-bundle.pem \
&& curl "" --output /etc/pki/ca-trust/source/anchors/rds-combined-ca-bundle.pem \
&& update-ca-trust \
&& update-ca-trust force-enable

On AWS Elastic Beanstalk the .ebextensions mechanism can be used. In the jar/war/etc deployment archive, add this file:


    bash: []
    curl: []
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      set -Eeuo pipefail # stop on all errors
      AVAILABILITY_ZONE=$(curl -s | grep region | cut -d\" -f4)
      if [[ ${AVAILABILITY_ZONE} == us-gov-* ]]
	curl "" --output /etc/pki/ca-trust/source/anchors/rds-combined-ca-us-gov-bundle.pem
	curl "" --output /etc/pki/ca-trust/source/anchors/rds-combined-ca-bundle.pem
      update-ca-trust force-enable
    command: "/tmp/"

Next, modify the client to require a secure connection. For example, with the PostgreSQL JDBC client, add “?ssl=true” to the connection string url.

That it – you can now connect to your RDS database using SSL/TLS with the assurance that no MITM (Man In The Middle) attacks, eavesdropping attacks, etc are possible.

CC BY-SA 4.0 Trusting AWS RDS Certificates in Docker and Beanstalk by Craig Andrews is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

One thought on “Trusting AWS RDS Certificates in Docker and Beanstalk

  1. Thank you Craig for your instructions, those helped me.
    In my case I first tested the commands by opening a session of my EC2 (beanstalk) and updated the certificates:

    In the EC2 session I execute
    1.- curl “” –output /etc/pki/ca-trust/source/anchors/rds-combined-ca-bundle.pemd:
    2.- sudo update-ca-trust
    3.- sudo update-ca-trust force-enable

    After seeing this actually working, then I modified my deployment script in CodeBuild.
    And in my jdbc connection, I just added the following parameter “?useSSL=true”

    Best regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.