---
name: "mysql_ssl_set"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_ssl_set"
---

# mysql\_ssl\_set(3)

### Name

mysql\_ssl\_set - Sets TLS/SSL options

### Synopsis

-

  ```
  #include <mysql.h>
  my_bool mysql_ssl_set(MYSQL *mysql,
                        const char *key,
                        const char *cert,
                        const char *ca,
                        const char *capath,
                        const char *cipher)
  ```

### Description

Used for establishing a secure TLS connection. It must be called before attempting to use **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**. TLS support must be enabled in the client library in order for the function to have any effect.

`NULL` can be used for an unused parameter. Always returns zero.

To enable TLS without specifying certificates, set all values to `NULL`:

-

  ```
  mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL)
  ```

This is the same as `mysql_optionsv(mysql, MYSQL_OPT_SSL_ENFORCE, &yes)`.

### Parameter

- •

  `mysql` - a mysql handle, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)**.

- •

  `key` - path to the key file.

- •

  `cert` - path to the certificate file.

- •

  `ca` - path to the certificate authority file.

- •

  `capath` - path to the directory containing the trusted TLS CA certificates in PEM format.

- •

  `cipher` list of permitted (SSLv3, TLSv1.0 or TLSv1.2) cipher suites to use for TLS encryption.

### Notes

- •

  **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)** will return an error if attempting to connect and TLS is incorrectly set up.

- •

  Even if Connector/C supports TLSv1.3 protocol, it is not possible yet to specify TLSv1.3 cipher suites via `cipher` parameter.

### See also

- •

  **[mysql\_get\_ssl\_cipher(3)](/mysql_get_ssl_cipher/3.md)**
