summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorDenis Kozadaev <[email protected]>2019-08-13 21:20:10 +0000
committerSlávek Banko <[email protected]>2019-08-31 18:46:58 +0200
commit4f528c3bd24f9bd833a559429a7960157322e445 (patch)
tree99a445747453c2200c11d02ff5a1af8b759656fc /src/sql
parent4e807343d7853e4b0565b12477d65034368b6b97 (diff)
downloadtqt3-4f528c3bd24f9bd833a559429a7960157322e445.tar.gz
tqt3-4f528c3bd24f9bd833a559429a7960157322e445.zip
add MYSQL_SSL_* to the driver for MySQL connections
Signed-off-by: Denis Kozadaev <[email protected]>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp25
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,