Learning center

Database TLS failing after an Amazon RDS certificate authority change

When clients that verify the server start failing against Amazon RDS, compare the instance's CA with the roots in the client's trust store. Clients pinned to an old CA bundle fail once the instance moves to a new CA, and instances still on rds-ca-2019 serve a chain that expired in August 2024. Read both sides before changing anything.

Who is affected#

Only clients that verify the server certificate notice a CA change. With libpq, sslmode=verify-ca checks the chain up to a root stored on the client, and verify-full also checks that the host name matches the certificate. require encrypts without verifying, except that libpq treats require like verify-ca when a root CA file exists, for backwards compatibility. The PostgreSQL JDBC driver with ssl=true validates the certificate and host name like verify-full. libpq SSL support · PostgreSQL JDBC SSL

The client error is an ordinary verification failure: unable to get local issuer certificate when the client lacks the new root, or certificate has expired when the instance still serves a chain under an expired CA. Java clients fail when the truststore they use lacks the RDS root. unable to get local issuer certificate

How RDS CAs change#

Each RDS instance has a CA certificate identifier that names the CA signing its server certificate. The current CAs are rds-ca-rsa2048-g1, rds-ca-rsa4096-g1 and rds-ca-ecc384-g1, and AWS's guidance moves instances to one of them. rds-ca-2019 expired in August 2024. RDS certificate rotation · RDS certificate authorities

Three events change what a client sees:

  • A CA change on the instance. Someone modifies the instance's CA identifier. By default the change waits for the next maintenance window unless it is applied immediately, so the failure can start at an hour nobody deployed anything.
  • A server certificate rotation under the same CA. For the three current CAs, RDS rotates the DB server certificate automatically and keeps the same root, so clients that trust the root need no new bundle. Engine versions that support rotation without restart get a new 12-month certificate in the maintenance window at the certificate's half life. Other engines get a pending maintenance action and a 36-month certificate.
  • An expired CA left in place. An instance still on rds-ca-2019 serves a certificate whose CA has expired, so verifying clients fail with an expiry error.

A client that pinned the server certificate itself, instead of the root, fails at every rotation. Automatic server certificate rotation

Read the instance side#

These calls only describe. CACertificateIdentifier is the instance's CA; CertificateDetails gives the CA of the current server certificate and its expiry; a CA change waiting for the maintenance window appears under PendingModifiedValues. describe-db-instances

aws rds describe-db-instances \
  --profile PROFILE --region REGION --db-instance-identifier DB_INSTANCE \
  --query 'DBInstances[0].{ca:CACertificateIdentifier,serverCertCa:CertificateDetails.CAIdentifier,serverCertValidTill:CertificateDetails.ValidTill,pendingCa:PendingModifiedValues.CACertificateIdentifier,engine:Engine,version:EngineVersion}' \
  --output json --no-cli-pager

List the CAs and their validity, and any pending rotation. describe-certificates returns each CA's ValidTill and whether an account-level override is set; describe-pending-maintenance-actions includes the action ca-certificate-rotation. describe-certificates · describe-pending-maintenance-actions

aws rds describe-certificates --profile PROFILE --region REGION \
  --query 'Certificates[].{id:CertificateIdentifier,validTill:ValidTill,override:CustomerOverride}' \
  --output table --no-cli-pager

aws rds describe-pending-maintenance-actions --profile PROFILE --region REGION \
  --query 'PendingMaintenanceActions[].{resource:ResourceIdentifier,actions:PendingMaintenanceActionDetails[].{action:Action,after:AutoAppliedAfterDate,current:CurrentApplyDate}}' \
  --output json --no-cli-pager

To learn whether the engine version can rotate without a restart, read SupportsCertificateRotationWithoutRestart from describe-db-engine-versions. describe-db-engine-versions

Read the client side#

Find the CA file the client uses: sslrootcert or PGSSLROOTCERT for libpq, otherwise ~/.postgresql/root.crt; the same default directory for the JDBC driver; javax.net.ssl.trustStore or the JDK's cacerts for other Java clients. Print the subjects in the file. AWS publishes a global bundle and regional bundles that contain all three current roots. RDS certificate bundles · openssl crl2pkcs7 · openssl pkcs7 -print_certs

openssl crl2pkcs7 -nocrl -certfile /etc/orders/rds-ca.pem \
  | openssl pkcs7 -print_certs -noout

keytool -list -v -keystore TRUSTSTORE_PATH

keytool -list prints the entries of a Java keystore without changing it. keytool

Then print the chain the instance serves. PostgreSQL negotiates TLS inside its own protocol, so s_client needs -starttls postgres; MySQL-family engines use -starttls mysql. openssl s_client -starttls

openssl s_client -connect DB_ENDPOINT:5432 -starttls postgres -showcerts \
  -CAfile /etc/orders/rds-ca.pem </dev/null 2>&1 \
  | grep -E 'depth=|verify error|Verify return code|s:|i:'

The issuer names in the chain identify the CA the instance uses. The Verify return code line shows whether the client's file is enough to verify it.

Read the result#

Instance CAClient's file holdsPoints to
A current G1 CAOnly the old 2019 rootClient bundle out of date
rds-ca-2019AnyInstance still on the expired CA
A current G1 CAThe matching G1 rootNot the CA; check host name and path
Pending CA changeThe current root onlyWill fail at the maintenance window

A worked example with two outcomes#

This example is illustrative. At 03:10 UTC on a Sunday, orders starts failing to connect to its RDS for PostgreSQL instance with sslmode=verify-full. No deploy ran.

In the first outcome, describe-db-instances shows rds-ca-rsa2048-g1, and describe-pending-maintenance-actions from Friday listed a ca-certificate-rotation. The orders image bundles a CA file with only the 2019 root. The CA change applied in the 03:00 maintenance window. The fix is the current bundle in the orders image; the database is serving a valid chain.

In the second outcome, the instance shows rds-ca-2019, and the s_client output reports certificate has expired at the root. orders trusts the global bundle, which includes the current roots. The instance has to move to a current CA, which is a change to the instance, with a restart if the engine version needs one. That decision belongs to the database's owner.

Limits#

The commands above read configuration and the served chain. They do not show which clients verify: a client using require without a root file keeps working through any CA change, so a quiet client is not proof of a correct bundle.

RDS Proxy, Aurora cluster endpoints and engines other than PostgreSQL have their own connection details; check the engine's page under the RDS SSL documentation. If the container image is the reason the bundle is stale, see container image CA bundle. For other layers, see the hub for runtime dependency failures.

Questions#

Does every server certificate rotation need a new bundle?

No. For rds-ca-rsa2048-g1, rds-ca-rsa4096-g1 and rds-ca-ecc384-g1, RDS rotates the server certificate under the same root, so a bundle holding that root keeps working. A CA change on the instance is different, since it changes the root.

Why did connections fail at night with no deploy?

CA changes and rotations that are not applied immediately run in the instance's maintenance window. Compare the failure time with the window and with the pending maintenance actions.

Is the global bundle enough for every Region?

AWS lists a global bundle for any commercial Region, another for the GovCloud (US) Regions, and a bundle per Region. Use the one that matches where the instance runs.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading