1

是否可以将 Propel 配置为使用与远程 MySQL 服务器的 SSL 连接?

我在 Doctrine 中发现了同样的问题,但也没有回答:How to connect to MySQL using SSL on symfony/doctrine

4

2 回答 2

1

这是运行时配置文件的示例:

$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);

这是推进配置文件的示例:

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
于 2015-04-16T13:48:14.780 回答
0

您可以使用连接选项来设置PDO SSL 属性

于 2014-07-27T00:50:23.363 回答