Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to mysql using ssl in Zend framework

Using this code I'm able to connect to mysql using zend framework normally:

resources.db.adapter = "Pdo_Mysql"
resources.db.params.host = "xx.xx.xx.xx"
resources.db.params.username = "test_user"
resources.db.params.password = "test_pass"
resources.db.params.dbname = "test_database"
resources.db.params.port="xxxx"

;parameters here for ssl connection??

In my Controller:

  public function indexAction() {
        $config = new Zend_Config_Ini('/path/to/application.ini', 'development');
        $db = Zend_Db::factory($config->resources->db);
        $sql = 'SELECT * FROM test_table';
        $result = $db->fetchAll($sql);

        echo '<pre>';
        print_r($result);
    }

Now the problem is that I want to connect to mysql using ssl, but I haven't found any documentation on how to do that.

I managed to make a connection using Navicat to the server with the help of the database admin by configuring the ssl connection as follows: enter image description here

The problem now is how to connect using php?

like image 439
Songo Avatar asked Dec 19 '12 17:12

Songo


1 Answers

You should be able to specify driver options like this:

;PDO::MYSQL_ATTR_SSL_KEY
resources.db.params.driver_options.1010 = "/path/to/client-key.pem"
;PDO::MYSQL_ATTR_SSL_CERT
resources.db.params.driver_options.1011 = "/path/to/client-cert.pem"
;PDO::MYSQL_ATTR_SSL_CA
resources.db.params.driver_options.1012 = "/path/to/ca-cert.pem"
like image 155
b.b3rn4rd Avatar answered Sep 21 '22 14:09

b.b3rn4rd