Name

mysql_ssl_set —

Synopsis

int mysql_ssl_set(MYSQL *mysql, char *key, char *certificate, char *authority,
                   char *authority_path)

Sets SSL information for the current connection and causes the connection to be made using SSL for encryption. This function must be called before mysql_real_connect to have any effect. The arguments are (beyond the pointer to the MYSQL structure) the text of the SSL public key used for the connection, the filename of the certificate used, the name of the authority that issued the certificate, and the directory that contains the authority’s certificates.

The function returns 0 on success and nonzero if an error occurs. The MySQL server and client both must have been compiled with SSL support for this function to work properly.

Example

/* 'key' contains an SSL public key.
   'cert' contains the filename of a certificate
   'ca' contains the name of the certificate authority
   'capath' contains the directory containing the certificate
*/
/* Create an initialized MYSQL structure using mysql_init */
mysql_ssl_set(&mysql, key, cert, ca, capath);
/* Now, when mysql_real_connect is called, the connection will use SSL for
   encryption. */

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.