add MYSQL_SSL_* to the driver for MySQL connections

Signed-off-by: Denis Kozadaev <denis@dilos.org>
pull/19/head
Denis Kozadaev 5 years ago committed by Slávek Banko
parent 4e807343d7
commit 4f528c3bd2

@ -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,

Loading…
Cancel
Save