my_bool mysql_ssl_set(MYSQL *mysql, const char *key,
const char *cert, const char *ca, const char *capath, const char
*cipher)
mysql_ssl_set() is used for
establishing secure connections using SSL. It must be called
before mysql_real_connect().
mysql_ssl_set() does nothing
unless SSL support is enabled in the client library.
Arguments:
mysql: The connection handler returned frommysql_init().key: The path name to the key filecert: The path name to the certificate fileca: The path name to the certificate authority filecapath: The path name to a directory that contains trusted SSL CA certificates in PEM formatcipher: A list of permissible ciphers to use for SSL encryption
The mysql argument must be a valid
connection handler. Any unused SSL arguments may be given as
NULL.
This function always returns 0. If SSL
setup is incorrect, a subsequent
mysql_real_connect() call
returns an error when you attempt to connect.
mysql_ssl_set() specifies SSL
information such as certificate and key files for establishing
a secure connection if such connections are available, but
does not enforce any requirement that the connection obtained
be secure. To require an encrypted connection, the standard
MySQL client programs use the following technique, which can
also be used by third-party applications:
If the
--ssl-mode=REQUIREDcommand-line option was specified, turn on SSL by callingmysql_ssl_set()to supply the appropriate SSL values. In addition, callmysql_options(), passing theMYSQL_OPT_SSL_MODEoption with a value ofSSL_MODE_REQUIRED. If themysql_options()call fails, exit with an error.Call
mysql_real_connect()to connect to the server. The call fails if an encrypted connection cannot be obtained.