Skip to content

Commit

Permalink
add secure connect(TLS) to mysql
Browse files Browse the repository at this point in the history
add secure connect(TLS) to mysql
  • Loading branch information
mem0rz authored and GreaterFire committed Mar 22, 2020
1 parent 9a048e4 commit b3a26ac
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/authenticator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ using namespace std;
Authenticator::Authenticator(const Config &config) {
mysql_init(&con);
Log::log_with_date_time("connecting to MySQL server " + config.mysql.server_addr + ':' + to_string(config.mysql.server_port), Log::INFO);
if (config.mysql.cafile.c_str() == NULL) {
} else if (config.mysql.tls_version.c_str() == NULL) {
mysql_ssl_set(&con, NULL, NULL, config.mysql.cafile.c_str(), NULL, NULL);
} else {
mysql_ssl_set(&con, NULL, NULL, config.mysql.cafile.c_str(), NULL, NULL);
mysql_optionsv(&con, MARIADB_OPT_TLS_VERSION, config.mysql.tls_version.c_str());
}
if (mysql_real_connect(&con, config.mysql.server_addr.c_str(),
config.mysql.username.c_str(),
config.mysql.password.c_str(),
Expand Down

0 comments on commit b3a26ac

Please sign in to comment.