Mysql PDO options to support SSL/TLS client communication (#15832)

* Fixed mysql connection to include additional options for SSL Cert and Key. This allows for TLS client communication.

* Modified config options for mysql database to make SSL/TLS settings optional.

SSL/TLS CA, CERT, and KEY are optional. If they are not provided the array_filter() will remove them.

MYSQL_ATTR_SSL_VERIFY_SERVER_CERT is outside array_filter() because the function will remove the option if it is falsey; however there are times when that variable must be set to false.

* fix style

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Shawn Kwang 2024-05-08 07:08:11 -05:00 committed by GitHub
parent c641b3fa94
commit 8027492a29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,8 +66,12 @@ return [
'strict' => true,
'engine' => null,
'sslmode' => env('DB_SSLMODE', 'disabled'),
'options' => extension_loaded('pdo_mysql') ? array_filter([
'options' => extension_loaded('pdo_mysql') ? [
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => env('MYSQL_ATTR_SSL_VERIFY_SERVER_CERT', false),
] + array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::MYSQL_ATTR_SSL_CERT => env('MYSQL_ATTR_SSL_CERT'),
PDO::MYSQL_ATTR_SSL_KEY => env('MYSQL_ATTR_SSL_KEY'),
]) : [],
],