Secure Propel connection, remote MySQL

↘锁芯ラ 提交于 2019-12-22 01:06:42

问题


Is it possible to configure Propel to use SSL connection with remote MySQL server?

I found the same question with Doctrine, but it isn't answered either: How to connect to MySQL using SSL on symfony/doctrine


回答1:


You can use the connection options to set PDO SSL attributes.




回答2:


Here's an example for the runtime config file:

$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setAdapterClass($db_name, 'mysql');
$manager = new ConnectionManagerSingle();
$manager->setConfiguration(array(
    'dsn' => 'mysql:host=' . $db_host . ';dbname=' . $db_name,
    'user' => $db_username,
    'password' => $db_password,
    'options' => [
        PDO::MYSQL_ATTR_SSL_KEY => '/etc/mysql/client-key.pem',
        PDO::MYSQL_ATTR_SSL_CERT => '/etc/mysql/client-cert.pem',
        PDO::MYSQL_ATTR_SSL_CA => '/etc/mysql/ca-cert.pem']
));
$serviceContainer->setConnectionManager('mydb', $manager);

And here's an example for the propel config file:

propel:
    database:
        connections:
            devServer:
                adapter: mysql
                classname: Propel\Runtime\Connection\DebugPDO
                dsn: mysql:host=myhost;dbname=mydb
                user: jomedia
                password: mypassword
                options:
                     1010 : /etc/mysql-certs/client-key.pem
                     1011 : /etc/mysql-certs/client-cert.pem
                     1012 : /etc/mysql-certs/ca-cert.pem


来源:https://stackoverflow.com/questions/17122558/secure-propel-connection-remote-mysql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!