Database SSL Connection Settings

My idea is:
Add support for SSL connection to the database (Useful for Cloud based DB)

I think these groups of people would benefit from this idea:
People that would like to use Cloud Based Databases

Why I think they would benefit from this idea:
Ease of setup

Any code or resources to support this idea:
Add two fields to local.php

  • ‘db_ssl’ => true
  • ‘db_ca_file’ => ‘pathtocafile’

And an if statement that adds
PDO::MYSQL_ATTR_SSL_CA => ‘%mautic.db_ca_file%’
to this section of the app/config/config.php file
$container->loadFromExtension(‘doctrine’, [
‘dbal’ => [
‘default_connection’ => ‘default’,
‘connections’ => [
‘default’ => $connectionSettings,
‘unbuffered’ => array_merge($connectionSettings, [
‘options’ => [
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false,
PDO::ATTR_STRINGIFY_FETCHES => true, // @see PHP: Backward Incompatible Changes - Manual
PDO::MYSQL_ATTR_SSL_CA => ‘%mautic.db_ca_file%’,
],
]),
],
‘types’ => [
Types::ARRAY => Type\ArrayType::class,
Types::DATETIME_MUTABLE => Type\UTCDateTimeType::class,
Types::DATETIME_IMMUTABLE => Type\UTCDateTimeImmutableType::class,
Type\GeneratedType::GENERATED => Type\GeneratedType::class,
],
],
‘orm’ => [
‘auto_generate_proxy_classes’ => ‘%kernel.debug%’,
‘auto_mapping’ => true,
‘mappings’ => $bundleMetadataBuilder->getOrmConfig(),
‘dql’ => [
‘string_functions’ => [
‘match’ => DoctrineExtensions\Query\Mysql\MatchAgainst::class,
],
],
‘result_cache_driver’ => [
‘type’ => ‘pool’,
‘pool’ => ‘doctrine_result_cache’,
],
],
]);
Are you willing to work on this idea?:
Unfortunately not a PHP or Mysql user.

What skills and resources do you need to explore this further?

Did you manage to connect making those alterations? is that info for Mautic 4 or Mautic 5 only? I have the same problem and am looking for a solution.

I created the db_ca_file field in config/local.php

and added PDO::MYSQL_ATTR_SSL_CA => ‘%mautic.db_ca_file%
to the app/config/config.php

And it working with a cloud based provider for me.
John

Just want to add that the settings are lost in the app/config/config.php when you upgrade your version.

John

I see that you add some parameters to local.php, but you alter also something in the config.php The related section on my system reads the following:

$container->loadFromExtension('doctrine', [
    'dbal' => $dbalSettings,
    'orm'  => [
        'auto_generate_proxy_classes' => '%kernel.debug%',
        'auto_mapping'                => true,
        'mappings'                    => $bundleMetadataBuilder->getOrmConfig(),
        'dql'                         => [
            'string_functions' => [
                'match' => \DoctrineExtensions\Query\Mysql\MatchAgainst::class,
            ],
        ],
    ],
]);

So do I need to add all the code you have there above? That is relevant for Mautic 4 and Mautic 5 alike? With which version did you test it? Because what I see the real magic happens there in the config.php

I am using Mautic 5
The parameters in the local.php are just for ease of editing as I would think that you wouldn’t want to mess around in the app/config/config.php too much :wink:
And where I put the PDO::MYSQL_ATTR_SSL_CA was above your orm section.
So, I am not sure where it would go in your config.php but I would be looking for what $dbalSettings is referencing
You probably have something just above.

John