mysql_ssl_set(3)

πŸ“¦
version 13.0.2 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– mysql_ssl_set β€” bestie, let's lock it down πŸ”

okay so this is mysql_ssl_set(3) from the MariaDB Connector/C manual, and it's literally the glow-up button for your database connection. TLS? yes ma'am. let's go πŸ¦‹


✨ 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)

look at her. six args. main character energy fr. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so what this one does is set you up for establishing a secure TLS connection. that's the whole vibe. πŸ”’βœ¨

⚠️ but bestie, listen β€” you have to call it before you even think about touching mysql_real_connect(3). like, before. not during. not after. before. πŸ™ˆ

also, and this is important: TLS support has to be enabled in the client library for this function to do literally anything. if it's not enabled, you're just out here calling a function into the void. πŸ’€

you can pass NULL for any parameter you're not using. and like, it always returns zero. always. zero. iconic consistency honestly.

want TLS but don't wanna mess with certificates at all? set every single value to NULL, like so:

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

that right there is the same thing as:

mysql_optionsv(mysql, MYSQL_OPT_SSL_ENFORCE, &yes)

same energy, different font. periodt. πŸ’…


🧚 PARAMETER 🧚

  • mysql β€” a mysql handle, which was previously allocated by mysql_init(3). your lil baby connection object 🫢
  • 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) will return an error if attempting to connect and TLS is incorrectly set up. so like… set it up correctly. 😭
  • Even if Connector/C supports TLSv1.3 protocol, it is not possible yet to specify TLSv1.3 cipher suites via the cipher parameter. no cap, that's just where we're at. πŸ₯²

🌈 SEE ALSO 🌈


Version 3.4 of the MariaDB Connector/C, bestie β€” that's the era we're living in. mwah, go encrypt something, i'm obsessed with you πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from