SSL Connections with ADODB
Question
I have a project we are about to wrap up, but just got a request from the DBA to make all our connections SSL. So I switched the driver to mysqli in the object that turns out ADODB instances, but I don't see any native method to create secure connections.
To make things more difficult, there is a different set of certs and keys per connection type (read and write).
Anyone have any ideas?
Solution
The trick is to use a DSN in the NewADOConnection() call (rather than authenticating with a Connect() call) and to use the mysqli driver. The DSN syntax allows you to supply client flags, and there's a mysqli flag for using SSL certificates.
$dsn = 'mysqli://ssluser:sslpass@dbhost/test?clientflags=2048';
$dbh = NewADOConnection($dsn);
$sql = "show status like 'ssl_cipher'";
$res =& $dbh->Execute($sql);
print_r( $res->fields );
$res->Close();
$dbh->Close();
The answer to this question is found at:
http://mbrisby.blogspot.com/2008/06/adodb-php-mysql-ssl.html
Here is the reference to MySQL Client Flags:
http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol
OTHER TIPS
I prefer the one with the Connect method, and clientFlags property.
$dbc = NewADOConnection('mysqli');
$dbc->clientFlags = CLIENT_SSL;
$this->dbc->Connect('dbhost', 'ssluser', 'sslpass', 'test');
Either of them would work.