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 Download the Amazon RDS CA bundle Point CodeIgniter’s MySQLi connection at that CA Verify the connection is encrypted (with either MySQL or MariaDB clients) 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)
|
1 2 3 4 5 |
sudo install -d -m 0755 /etc/ssl/certs sudo curl -fSLo /etc/ssl/certs/rds-combined-ca-bundle.pem \ https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem sudo chmod 0644 /etc/ssl/certs/rds-combined-ca-bundle.pem |
Without root (per-site location, safe for Plesk)
|
1 2 3 4 5 |
mkdir -p /var/www/vhosts/example.com/private/ssl/rds curl -fSLo /var/www/vhosts/example.com/private/ssl/rds/rds-combined-ca-bundle.pem \ https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem chmod 0644 /var/www/vhosts/example.com/private/ssl/rds/rds-combined-ca-bundle.pem |
Sanity checks:
|
1 2 3 4 |
grep -c "BEGIN CERTIFICATE" /path/to/rds-combined-ca-bundle.pem openssl crl2pkcs7 -nocrl -certfile /path/to/rds-combined-ca-bundle.pem \ | openssl pkcs7 -print_certs -noout | head |
Plesk note: if PHP has open_basedir