2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#3256] convert mysql_ssl_set to mysql_options

This commit is contained in:
Andrei Pavel
2024-05-15 19:09:21 +03:00
parent 0fcf61ea21
commit 6e708a1e07
2 changed files with 21 additions and 2 deletions

View File

@@ -237,8 +237,12 @@ MySqlConnection::openDatabase() {
// 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.

View File

@@ -1008,4 +1008,19 @@ TEST_F(MySqlConnectionTest, toKeaAdminParameters) {
"--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