comparison Framework/MySQL/MySQLDatabase.cpp @ 163:4d32c9c8d6c0

Added support for TLS connections
author Alain Mazy <alain@mazy.be>
date Mon, 13 Jul 2020 11:59:29 +0200
parents 275e14f57f1e
children 0632c2408af3
comparison
equal deleted inserted replaced
162:fc13b4e8f888 163:4d32c9c8d6c0
138 { 138 {
139 // Fallback to TCP connection if no UNIX socket is provided 139 // Fallback to TCP connection if no UNIX socket is provided
140 unsigned int protocol = MYSQL_PROTOCOL_TCP; 140 unsigned int protocol = MYSQL_PROTOCOL_TCP;
141 mysql_options(mysql_, MYSQL_OPT_PROTOCOL, (unsigned int *) &protocol); 141 mysql_options(mysql_, MYSQL_OPT_PROTOCOL, (unsigned int *) &protocol);
142 } 142 }
143 143
144 if (parameters_.IsSsl())
145 {
146 if (parameters_.IsVerifyServerCertificates())
147 {
148 my_bool verifyCert = 1;
149 mysql_options(mysql_, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (void *) &verifyCert);
150 mysql_optionsv(mysql_, MYSQL_OPT_SSL_CA, (void *)(parameters_.GetSslCaCertificates()));
151 }
152
153 my_bool enforceTls = 1;
154 mysql_options(mysql_, MYSQL_OPT_SSL_ENFORCE, (void *) &enforceTls);
155 }
156
144 const char* socket = (parameters_.GetUnixSocket().empty() ? NULL : 157 const char* socket = (parameters_.GetUnixSocket().empty() ? NULL :
145 parameters_.GetUnixSocket().c_str()); 158 parameters_.GetUnixSocket().c_str());
146 159
147 if (mysql_real_connect(mysql_, 160 if (mysql_real_connect(mysql_,
148 parameters_.GetHost().c_str(), 161 parameters_.GetHost().c_str(),