Encrypted Database Connections
Encrypting rConfig Database Connections with TLS (V8.3.2+)
Section titled “Encrypting rConfig Database Connections with TLS (V8.3.2+)”rConfig V8.3.2 and later can encrypt the connection between the application and its MySQL, MariaDB, or PostgreSQL database using TLS. After reading this page, you can configure certificate paths in .env, mount certificates into container deployments, and verify that traffic to the database is encrypted.
When to use this
Section titled “When to use this”Use this guide when your database runs on a separate host from rConfig and traffic between them crosses a network you do not fully trust, or when a security policy (PCI DSS, ISO 27001, internal hardening standards) requires encryption in transit for all database connections. If rConfig and its database run on the same host and connect over localhost or a UNIX socket, TLS adds little benefit.
Prerequisites
Section titled “Prerequisites”- rConfig V8.3.2 or later. Earlier versions ignore these settings, although PostgreSQL connections before V8.3.2 already used a hardcoded
sslmodeofprefer: opportunistic encryption when the server offers TLS, with no certificate verification and silent fallback to plaintext. - A database server already configured to accept TLS connections, with its CA certificate available to copy to the rConfig host. Enabling TLS on the database server itself is covered by the MySQL, MariaDB, and PostgreSQL vendor documentation.
- A client certificate and key pair, only if your database server enforces mutual TLS.
- Shell access to the rConfig server (or container host) with permission to edit
.env.
Copy the certificates to the rConfig host
Section titled “Copy the certificates to the rConfig host”-
Create a directory for the certificates. The examples below use the same paths as the commented template in
.env.example:Terminal window mkdir -p /etc/ssl/mariadb # MySQL and MariaDBmkdir -p /etc/ssl/postgres # PostgreSQL -
Copy the CA certificate (and the client certificate and key, if using mutual TLS) into that directory.
-
Make the files readable by the web server user:
Terminal window chown -R root:apache /etc/ssl/mariadbchmod 640 /etc/ssl/mariadb/*
Configure the .env file
Section titled “Configure the .env file”Edit .env in the rConfig application root and add the settings for your database engine. The variables are already present as a commented template in .env.example.
Both MySQL and MariaDB use DB_CONNECTION=mysql. Setting MYSQL_ATTR_SSL_CA alone is enough to enable an encrypted connection; the client certificate and key are only needed when the server enforces mutual TLS.
MYSQL_ATTR_SSL_CA=/etc/ssl/mariadb/ca.pemMYSQL_ATTR_SSL_VERIFY_SERVER_CERT=true
# Only for mutual TLS:MYSQL_ATTR_SSL_CERT=/etc/ssl/mariadb/client-cert.pemMYSQL_ATTR_SSL_KEY=/etc/ssl/mariadb/client-key.pemSet MYSQL_ATTR_SSL_VERIFY_SERVER_CERT=false only if the server certificate’s hostname does not match your DB_HOST value (common with self-signed certificates issued to another name). Leaving verification on protects against man-in-the-middle attacks, so treat false as a last resort.
The same certificate paths are passed automatically to mysqldump for scheduled database backups, so no separate backup configuration is needed.
PostgreSQL connections (DB_CONNECTION=pgsql) use the standard libpq sslmode values: disable, allow, prefer, require, verify-ca, and verify-full. rConfig defaults to prefer when DB_SSLMODE is not set.
DB_SSLMODE=verify-fullDB_SSLROOTCERT=/etc/ssl/postgres/root.crt
# Only for mutual TLS:DB_SSLCERT=/etc/ssl/postgres/client.crtDB_SSLKEY=/etc/ssl/postgres/client.keyUse verify-full where the server certificate’s hostname matches DB_HOST, and verify-ca where it does not. Both validate the certificate against DB_SSLROOTCERT.
Container deployments: mount the certificates
Section titled “Container deployments: mount the certificates”The rConfig V8 Pro container cannot read certificates that only exist on the host, and the .env paths must be valid inside the container. Mount the certificate directory into the container at the same path referenced by .env.
-
Place the certificates on the container host, for example under
/home/rconfig/certs/. -
Add a read-only bind mount to the rConfig service in the supplied
docker-compose.yml, alongside the existing volume entries:volumes:# ... existing rConfig volume mappings, unchanged ...- /home/rconfig/certs:/etc/ssl/mariadb:ro # or /etc/ssl/postgres for PostgreSQL -
Set the
.envcertificate paths to the in-container path (/etc/ssl/mariadb/ca.pem), not the host path. -
Recreate the container so the new mount takes effect:
Terminal window docker compose up -d
Apply the configuration
Section titled “Apply the configuration”-
Clear the cached configuration so the new settings load:
Terminal window cd /var/www/html/rconfig8/currentphp artisan rconfig:clear-allOn container deployments, run the same command inside the container:
docker exec -it <container_name> php artisan rconfig:clear-all. -
Restart the queue workers so long-running processes pick up the new connection settings:
Terminal window systemctl restart supervisordOn container deployments, restarting the container in the previous section already covers this.
Verify the connection is encrypted
Section titled “Verify the connection is encrypted”Run the check through rConfig itself so you are testing the application’s own connection, not a separate client session.
cd /var/www/html/rconfig8/currentphp artisan tinker --execute="print_r(DB::select(\"SHOW STATUS LIKE 'Ssl_cipher'\"));"An encrypted connection returns a cipher name:
[Value] => TLS_AES_256_GCM_SHA384An empty Value means the connection is not encrypted. Re-check the .env paths and confirm the database server has TLS enabled.
cd /var/www/html/rconfig8/currentphp artisan tinker --execute="print_r(DB::select('SELECT ssl, version, cipher FROM pg_stat_ssl WHERE pid = pg_backend_pid()'));"An encrypted connection returns ssl => true with the negotiated TLS version and cipher. ssl => false means the session fell back to plaintext.