ZF-6140: Secure connection to mysql with Zend


I need connect to mysql server that use secure(ssl) connection.

Mysqli have method to setup ssl - bool mysqli::ssl_set ( string $key , string $cert , string $ca , string $capath , string $cipher ).

With Zend I try use this code:

$dbAdapter=Zend_Db::factory($this->_config->production->database); $dbAdapter->getConnection()->ssl_set('client-key.pem', 'client-cert.pem', 'ca-cert.pem',NULL,NULL);

But Zend initiates the connection before ssl sertificates are set and I get mysql connection error.

How I can connect to remote mysql server with mysqli and Zend?


I would also like to see Zend Framework support SSL connections to MySQL. I've attached a patch which made it work for me. The following is a code sample (using the patched Zend_Db_Adapter_Mysqli):

$db_attr_ref = array( 'host' => '', 'username' => 'user', 'password' => 'pass', 'dbname' => 'db', 'driver_options' => array( 'realConnectFlags' => MYSQLI_CLIENT_SSL, 'sslCipher' => 'DHE-RSA-AES256-SHA', ), ); $dbh = Zend_Db::factory('Mysqli', $db_attr_ref);