-
-
Save etenzy/b62baad6f0f283e3509ff16c2b43b7f7 to your computer and use it in GitHub Desktop.
Laravel PostgreSQL SSL encryption connection config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 1. You have to store your client SSL certificates on your Laravel server, in my case this is /var/certs/mydomain.com/... | |
| * 2. You have to right select SSL mode for PostgreSQL (see https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS), verify-full means your server CA is signed for real domain name for the PostgreSQL server (recommended) | |
| * 3. Go to Laravel config/database.php to the section 'pgsql' and extend it to the following: | |
| */ | |
| return [ | |
| /*...*/ | |
| 'connections' => [ | |
| /*'mysql' etc*/ | |
| 'pgsql' => [ | |
| /*driver, host, database, username etc*/ | |
| 'sslmode' => 'verify-ca', //depends on your security level https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS | |
| 'options' => [ | |
| 'sslrootcert' => '/var/certs/mysite.com/postgresql-root.crt', | |
| 'sslcert' => '/var/certs/mysite.com/postgresql-client.crt', | |
| 'sslkey' => '/var/certs/mysite.com/postgresql-client.key', | |
| ] | |
| ] | |
| ] | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment