// If TLS is enabled set it. If something should go wrong it will happen
// later at the mysql_real_connect call.
if (tls_) {
- mysql_ssl_set(mysql_, key_file, cert_file, ca_file, ca_dir,
- cipher_list);
+ mysql_options(mysql_, MYSQL_OPT_SSL_KEY, key_file);
+ mysql_options(mysql_, MYSQL_OPT_SSL_CERT, cert_file);
+ mysql_options(mysql_, MYSQL_OPT_SSL_CA, ca_file);
+ mysql_options(mysql_, MYSQL_OPT_SSL_CAPATH, ca_dir);
+ mysql_options(mysql_, MYSQL_OPT_SSL_CIPHER, cipher_list);
+
}
// Open the database.
"--ssl-ca " TEST_CA_DIR "/kea-ca.crt", "--user", "keatest_secure"}));
}
+/// @brief Checks that the mysql_options call does not crash when passed a null option value.
+///
+/// An unconventional test, but the MySQL docs are not clear:
+/// > Any unused SSL arguments may be given as NULL.
+/// > Because of that equivalence, applications can, instead of calling mysql_ssl_set(), call
+/// mysql_options() directly, omitting calls for those options for which the option value is NULL.
+TEST_F(MySqlConnectionTest, mysqlOptions) {
+ MySqlHolder mysql;
+ mysql_options(mysql, MYSQL_OPT_SSL_KEY, nullptr);
+ mysql_options(mysql, MYSQL_OPT_SSL_CERT, nullptr);
+ mysql_options(mysql, MYSQL_OPT_SSL_CA, nullptr);
+ mysql_options(mysql, MYSQL_OPT_SSL_CAPATH, nullptr);
+ mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, nullptr);
+}
+
} // namespace