Published 2 months ago by bcharron
I am trying to connect to a SSL enabled database with a Laravel application, but when I do so, I get a bad gateway error. Per a few different resources, I found the following configuration for the MySQL driver to add support for SSL connections, but with this driver configuration, I get the Bad Gateway error.
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'sslmode' => env('DB_SSLMODE', 'prefer'), 'options' => [ PDO::MYSQL_ATTR_SSL_CA => '/path/to/file/ca.pem', PDO::MYSQL_ATTR_SSL_CERT => '/path/to/file/client-cert.pem', PDO::MYSQL_ATTR_SSL_KEY => '/path/to/file/client-key.pem' ], 'strict' => true, 'engine' => null, ],
I am using Laravel Valet as the development environment for this. I get the following error in the Valet NGINX error log:
2018/06/14 07:51:50 [error] 6495#0: *15 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: ccc.dev, request: "POST /oauth/token HTTP/1.1"
Does anyone know how to resolve this issue with a SSL enabled DB connection in a Laravel application or on Valet?
@jdc1898 I have not tried that, but this link seems to be specific to AWS RDS, which we are not using.
EDIT: I used the function
mysql_ssl_rsa_setup documented here: https://dev.mysql.com/doc/refman/8.0/en/creating-ssl-rsa-files-using-mysql.html to generated the keys.