Laravel与sslmode中的PostgreSQL [英] Laravel with PostgreSQL in sslmode

查看:66
本文介绍了Laravel与sslmode中的PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS开发一个项目,该项目托管在带有RDS PostgreSQL的EC2实例上.我想在服务器和数据库之间使用SSL加密,

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?

推荐答案

这似乎是Laravel 4中缺少的功能,但我已提交拉动请求以解决此问题.

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 (于2014-09-08合并)

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

要修补代码,只需将以下代码段添加到PostgresConnector.php文件中的 getDsn 函数中.

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}";
}

然后,您可以在pgsql数据库配置部分中指定 sslmode ='require'来测试Web应用程序与数据库之间的加密.sslmode的其他可能值是'disable''allow''prefer''require''verify-ca''verify-full'.默认值为'prefer'.

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'.

有关更多信息,请查看PostgreSQL文档: http://www.postgresql.org/docs/9.3/static/libpq-ssl.html

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

这篇关于Laravel与sslmode中的PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆