Modern cPanel installs ship MySQL with TLS support enabled — the server generates a certificate at install time and the daemon offers STARTTLS to clients. What it doesn’t do is require TLS. A client that connects without negotiating TLS gets a cleartext connection, and the credentials cross the network unencrypted. For a remote MySQL grant that allows access from 203.0.113.42, that’s a one-tcpdump-away credential leak. Enforcement is per-user and requires the GRANT to specify it.
What’s happening
MySQL’s TLS lifecycle on cPanel:
- Server-side TLS: cPanel generates
/var/lib/mysql/ca.pem,server-cert.pem, andserver-key.pemon install. MySQL reads these viassl_ca,ssl_cert,ssl_keyin the config (or defaults to those paths). The daemon advertises TLS support to clients. - Client-side: a client connecting with
--ssl-mode=REQUIREDor--ssl=1negotiates TLS. Without that, the connection goes cleartext. - Per-user requirement:
REQUIRE SSLon the GRANT forces the client to negotiate TLS. Without it, the server accepts cleartext from clients that don’t ask for TLS.
So even with TLS available, the deployment is only secure if both: clients are configured to ask for TLS, AND grants require it. The first protects against accidental cleartext; the second protects against the client config being wrong.
How to verify
mysql -e "SHOW VARIABLES LIKE 'have_ssl'"
mysql -e "SHOW VARIABLES LIKE 'ssl%'"
mysql -e "SELECT User, Host, ssl_type FROM mysql.user WHERE Host NOT IN ('localhost','127.0.0.1','::1')"
mysql -u remote_user -p -h 203.0.113.42 --ssl-mode=REQUIRED -e "SHOW STATUS LIKE 'Ssl_cipher'"
ls -la /var/lib/mysql/*.pem
have_ssl = YES means TLS is available. The ssl_type column shows what each user is required to negotiate (ANY, SSL, X509, SPECIFIED). Ssl_cipher non-empty means the connection actually negotiated TLS.
The fix
- Confirm server TLS works:
Ifmysql -e "SHOW STATUS LIKE 'Ssl_cipher'" mysql -e "SHOW VARIABLES LIKE 'have_openssl'"have_openssl = YESand the cipher list isn’t empty, you’re set up. - For each remote user, require SSL:
This addsALTER USER 'acmecorp_app'@'203.0.113.42' REQUIRE SSL; FLUSH PRIVILEGES;ssl_type = ANYto that user. Any future connection from this user must negotiate TLS or be rejected. - For stricter posture, require an X.509 client certificate:
The client must present a valid certificate, signed by the server’s CA. This is mTLS — both sides authenticate cryptographically. Stronger but requires distributing client certs.ALTER USER 'acmecorp_app'@'203.0.113.42' REQUIRE X509; - For grants created via cPanel API, the REQUIRE clause isn’t directly exposed in UAPI. You have to ALTER USER after the API creates the grant. Script this as a post-create hook if it’s a regular workflow.
- For clients (PHP, applications), configure them to ask for TLS:
- PHP/PDO:
PDO::MYSQL_ATTR_SSL_CAand friends. - WP-CLI / mysql client:
--ssl-mode=REQUIRED. - PHP/mysqli:
mysqli_ssl_set()before connect. - Connection strings:
?sslmode=requirein DSN-style.
- PHP/PDO:
- Test the enforcement: try to connect without TLS:
Should returnmysql -u acmecorp_app -p -h server.example.com --ssl-mode=DISABLED -e "SELECT 1"ERROR 1045: Access denied ... SSL connection erroror similar. If the connection succeeds, REQUIRE SSL didn’t take effect. - Verify the established connection is encrypted:
Returns the cipher in use. Empty cipher means TLS wasn’t negotiated (somehow connected cleartext).mysql -u acmecorp_app -p -h server.example.com --ssl-mode=REQUIRED -e "SHOW STATUS LIKE 'Ssl_cipher'" - Renew certificates before expiry. cPanel-generated certs have a 10-year validity. If you use Let’s Encrypt or a custom CA, automate renewal — an expired cert breaks all TLS-required connections.
- For
'user'@'%'grants (which you should not have — see remote MySQL article), REQUIRE SSL on them too. A%wildcard grant requiring TLS is still riskier than an IP-specific grant requiring TLS, but it’s better than cleartext.
For environments where Remote MySQL is used and credential exposure is a real concern, Stack Harbor’s environment management team enforces REQUIRE SSL on every non-localhost grant, automates certificate renewal, and audits cipher strength against current security baselines.