Symfony : how to set SSL parameters in Doctrine DBAL configuration (YAML)?

后端 未结 6 1869
误落风尘
误落风尘 2021-02-09 10:56

I\'d like to add my SSL cert and key files to Doctrine DBAL configuration but I don\'t see how to achieve that.

In PHP, I just have to write something like :

<         


        
6条回答
  •  迷失自我
    2021-02-09 11:19

    An alternative approach would be installing composer/ca-bundle to help find the path to the CA root bundle and use a custom compiler pass to automagically register that path with Doctrine:

    getParameter('doctrine.connections') ?? [] as $connectionName) {
                $definition = $container->getDefinition($connectionName);
                $options = $definition->getArgument(0) ?? [];
                $options['driverOptions'][\PDO::MYSQL_ATTR_SSL_CA] = $caPathOrFile;
                $definition->setArgument(0, $options);
            }
        }
    }
    

提交回复
热议问题