Enabling TLS for CodeIgniter (MySQLi) on Amazon RDS

Transport Layer Security (TLS) encrypts traffic between your app and database, protecting credentials and data in transit. This guide shows how to enable and verify TLS for a CodeIgniter 4 app using the MySQLi driver against Amazon RDS/Aurora MySQL—whether you have root on the host or not. It also covers enforcing TLS at the database and common pitfalls.

What you’ll do

  1. Download the Amazon RDS CA bundle
  2. Point CodeIgniter’s MySQLi connection at that CA
  3. Verify the connection is encrypted (with either MySQL or MariaDB clients)
  4. Optionally require TLS at the DB parameter group level

1) Get the Amazon RDS CA bundle

Use either the global bundle (works for all commercial regions) or a region-specific bundle (e.g., us-east-1).

  • Global (covers any commercial region):
    https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
  • Regional example (N. Virginia):
    https://truststore.pki.rds.amazonaws.com/us-east-1/us-east-1-bundle.pem

With root (system-wide location)

Without root (per-site location, safe for Plesk)

Sanity checks:

Plesk note: if PHP has open_basedir restrictions, include the chosen path under the domain’s PHP settings.


2) Configure CodeIgniter 4 (MySQLi) for TLS

CodeIgniter’s MySQLi driver supports TLS via the encrypt option. Provide the CA bundle path and enable verification.

Option A — app/Config/Database.php

Option B — via .env (recommended for secrets)

In app/Config/Database.php, decode if present:


3) Verify the connection is encrypted

A) Using the Oracle MySQL client (supports --ssl-mode)

B) Using the MariaDB client (no --ssl-mode)

If mysql --version shows “MariaDB”, use:

Which client do I have?

From inside your app (works the same regardless of client):

A non-empty Ssl_cipher confirms TLS is active.


4) Enforce TLS on the database (recommended)

Set require_secure_transport = ON in your RDS (MySQL) DB parameter group (or Aurora MySQL cluster parameter group) to reject plaintext connections.


Troubleshooting

  • mysql: unknown variable 'ssl-mode=VERIFY_CA'
    You’re using the MariaDB client. Use --ssl + --ssl-verify-server-cert instead (see 3B).
  • “AccessDenied” when downloading the bundle
    Use the exact paths shown above (/global/global-bundle.pem or /<region>/<region>-bundle.pem).
  • “Certificate verify failed”
    Ensure the CA path is correct and readable by the PHP-FPM user; verify with ls -l and check open_basedir.
  • RDS Proxy
    When connecting through RDS Proxy, it uses ACM-managed certificates; clients normally don’t need to fetch a separate trust store.

Security checklist

  • Enforce verification (--ssl-mode=VERIFY_CA or --ssl-verify-server-cert / ssl_verify: true).
  • Store credentials in .env, not in the repository.
  • Keep the CA bundle out of web root (e.g., private/ssl/rds/).
  • Consider pinning TLS versions/ciphers if your policy requires it.

Appendix: Copy-paste blocks

Global bundle to a per-site path (non-root):

MySQL client verification (Oracle client):

MariaDB client verification:

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

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

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.