Answer a question

I'm working on a project using AWS, hosted on an EC2 instance with a RDS PostgreSQL. I'm wanting to make use of SSL encryption between my server and database, something AWS RDS supports but I can't figure out how to configure Laravel to make it work. Is there a way to specify sslmode when configuring a database connections?

Answers

This seems to be a missing feature in Laravel 4, but I have submitted a pull request to fix this.

https://github.com/laravel/framework/pull/5488 (was merged on 2014-09-08)

To patch the code just add the following snippet to the getDsn function in the PostgresConnector.php file.

if (isset($config['sslmode']))
{
    $dsn .= ";sslmode={$sslmode}";
}

After that you may specify sslmode = 'require' in the pgsql database config section to test the encryption between the web app and your database. Other possible values for sslmode are 'disable', 'allow', 'prefer', 'require', 'verify-ca', 'verify-full'. The default value is 'prefer'.

For further info check the PostgreSQL docs: http://www.postgresql.org/docs/9.3/static/libpq-ssl.html

Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐