Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use PDO::MYSQL_ATTR_SSL_CA with Propel ORM

I'm trying to reverse engineer a database with Propel reverse command. The database I'm trying to connect to requires a SSL certificate, this is how I connect to it in my application:

new PDO(
    'mysql:host=localhost;dbname=blog',
    'root', '', array(PDO::MYSQL_ATTR_SSL_CA => '/path/ssl-cert.crt'
);

My Propel config file:

propel:
  database:
    connections:
      blog:
        adapter: mysql
        classname: Propel\Runtime\Connection\ConnectionWrapper
        dsn: "mysql:host=localhost;dbname=blog"
    user: root
    password:
    options:
      PDO::MYSQL_ATTR_SSL_CA: /path/ssl-cert.crt

I get the following error:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "PDO::MYSQL_ATTR_SSL_CA" under "propel.database.connections.gateway.options" 

I read this post: Secure Propel connection, remote MySQL, the first answer link to an old version of Propel, and I also tried the alternative answer, replacing PDO::MYSQL_ATTR_SSL_CA by its integer value. Nothing worked, has anyone had this problem before? What am I missing?

like image 488
Tchoupi Avatar asked Jul 09 '26 13:07

Tchoupi


1 Answers

It seems that only ATTR_PERSISTENT option is supported at the moment: PropelConfiguration

It should be fairly easy to fork it and patch with something like:

->arrayNode('options')
    ->children()
        ->booleanNode('ATTR_PERSISTENT')->defaultFalse()->end()
        ->scalarNode('PDO::MYSQL_ATTR_SSL_CA')->end()
    ->end()
->end()

I would recommend to add this scalar node directly in your vendor/propel/propel/src/Propel/Common/Config/PropelConfiguration.php and check if there are any hidden bugs or missing functionality.

like image 63
Alex Blex Avatar answered Jul 11 '26 02:07

Alex Blex