Safeguard
Security Guides•

MySQL TLS: require_secure_transport and client ssl-mode explained

Server settings can force encrypted MySQL connections, but clients still need ssl-mode VERIFY_IDENTITY to stop impostors. Here is how the pieces fit.

Safeguard Security Team
3 min read

To enforce encryption in MySQL, set require_secure_transport=ON on the server so it rejects unencrypted TCP connections. To make sure clients talk to the real server, set their ssl-mode to VERIFY_IDENTITY, or VERIFY_CA at minimum. The server setting and the client setting protect against different things.

What the server setting does

The MySQL manual says that with require_secure_transport enabled, clients must use some form of secure transport. The server permits only TCP/IP connections that use SSL, or connections over a Unix socket file or shared memory. Insecure attempts are rejected with an ER_SECURE_TRANSPORT_REQUIRED error.

[mysqld]
require_secure_transport=ON

At runtime, SET PERSIST require_secure_transport=ON; keeps the change across restarts. Test in staging first, because any client still connecting without TLS will begin to fail.

Per account requirements

You can also require encryption for specific accounts with a REQUIRE clause on CREATE USER or ALTER USER. The manual shows REQUIRE X509 for certificate based login, and REQUIRE SSL is another valid form. This is useful when you cannot flip the whole server at once and want to start with the accounts that matter most, such as administrators and anything used from outside your network.

Client ssl-mode values

The manual lists these client modes:

ModeBehavior
PREFERRED (default)Tries encryption, falls back to unencrypted
REQUIREDFails if encryption cannot be established
DISABLEDNo encryption
VERIFY_CAEncrypted, and verifies the server certificate against the CA
VERIFY_IDENTITYAs VERIFY_CA, and checks the host name matches the certificate

The default is the weak one. It encrypts when it can and silently continues without it, so a network attacker who blocks the TLS handshake wins. The manual recommends VERIFY_CA or VERIFY_IDENTITY to protect against man in the middle attacks.

Why identity matters

Encryption without verification protects against someone reading traffic, but not against someone pretending to be your database. VERIFY_IDENTITY makes the client check that the host name it dialed matches the server certificate. The manual notes this does not work with server generated self signed certificates because they lack the server name as the common name. Issue a certificate from a CA your clients trust, and distribute the CA certificate to them.

The same logic applies in PostgreSQL, where require and verify-full split the same way. See PostgreSQL sslmode compared.

Rollout order

  1. Inventory clients and their connection options.
  2. Install a proper server certificate and distribute the CA certificate.
  3. Move clients to VERIFY_IDENTITY, one service at a time.
  4. Turn on require_secure_transport once nothing connects in the clear.
  5. Use tls_version to prevent clients from using less secure protocols. The manual points to its TLS protocols section for defaults, so read that for your version.

Quick check

Does require_secure_transport verify the server certificate?

No. It makes the server refuse unencrypted TCP connections. Certificate checking happens on the client through ssl-mode VERIFY_CA or VERIFY_IDENTITY.

Are local socket connections affected?

The manual says Unix socket and shared memory connections are still permitted when the setting is on.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.