diff options
author | Denis Kozadaev <denis@dilos.org> | 2019-08-13 21:20:10 +0000 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2019-08-31 19:01:23 +0200 |
commit | 63201b0193c88494a7d7fb6bc20aefb4a1dde350 (patch) | |
tree | e6297b373735e4b81b7aa4647ddfa1351af40624 | |
parent | 109ddbde51a41712f1257e3071852018ac15d66f (diff) | |
download | tqt3-63201b0193c88494a7d7fb6bc20aefb4a1dde350.tar.gz tqt3-63201b0193c88494a7d7fb6bc20aefb4a1dde350.zip |
add MYSQL_SSL_* to the driver for MySQL connections
Signed-off-by: Denis Kozadaev <denis@dilos.org>
(cherry picked from commit 4f528c3bd24f9bd833a559429a7960157322e445)
-rw-r--r-- | src/sql/drivers/mysql/qsql_mysql.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 5178e7a79..48337f884 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -481,15 +481,27 @@ bool TQMYSQLDriver::open( const TQString& db, TQStringList raw = TQStringList::split( ';', connOpts ); TQStringList opts; TQStringList::ConstIterator it; + TQString ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher; // extract the real options from the string for ( it = raw.begin(); it != raw.end(); ++it ) { - TQString tmp( *it ); + TQString tmp( *it ), name; int idx; if ( (idx = tmp.find( '=' )) != -1 ) { TQString val( tmp.mid( idx + 1 ) ); val.simplifyWhiteSpace(); - if ( val == "TRUE" || val == "1" ) + name = tmp.left( idx ); + if (name == "MYSQL_SSL_KEY") + ssl_key = val; + else if (name == "MYSQL_SSL_CERT") + ssl_cert = val; + else if (name == "MYSQL_SSL_CA") + ssl_ca = val; + else if (name == "MYSQL_SSL_CAPATH") + ssl_capath = val; + else if (name == "MYSQL_SSL_CIPHER") + ssl_capath = val; + else if ( val == "TRUE" || val == "1" ) opts << tmp.left( idx ); else tqWarning( "TQMYSQLDriver::open: Illegal connect option value '%s'", tmp.latin1() ); @@ -528,6 +540,15 @@ bool TQMYSQLDriver::open( const TQString& db, tqWarning( "TQMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() ); } + if (clientOptionFlags & CLIENT_SSL) { + mysql_ssl_set(d->mysql, + ssl_key.isEmpty()? static_cast<const char *>(0):ssl_key.local8Bit(), + ssl_cert.isEmpty()? static_cast<const char *>(0):ssl_cert.local8Bit(), + ssl_ca.isEmpty()? static_cast<const char *>(0):ssl_ca.local8Bit(), + ssl_capath.isEmpty()? static_cast<const char *>(0):ssl_capath.local8Bit(), + ssl_cipher.isEmpty()? static_cast<const char *>(0):ssl_cipher.local8Bit() + ); + } mysql_options(d->mysql, MYSQL_OPT_RECONNECT, &reconnect); if ( mysql_real_connect( d->mysql, |