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:
@@ -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.
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user