kenpeter
kenpeter

Reputation: 8274

Connect laravel 5 to AWS RDS with SSL

I was reading this question and this article.

'your_connection' => array(
  'driver'  => 'mysql',
  'host'    => $host,
  'database'  => $database,
  'username'  => $username,
  'password'  => $password,
  'charset'   => 'utf8',
  'collation' => 'utf8_unicode_ci',
  'prefix'  => '',
  'options' => array(
    PDO::MYSQL_ATTR_SSL_KEY => $cert_base . '/client-key.pem',
    PDO::MYSQL_ATTR_SSL_CERT => $cert_base . '/client-cert.pem',
    PDO::MYSQL_ATTR_SSL_CA => $cert_base . '/ca-cert.pem'
  ),
),

From what I understand, PDO::MYSQL_ATTR_SSL_CA, is can be downloaded from here

I am not sure PDO::MYSQL_ATTR_SSL_KEY and PDO::MYSQL_ATTR_SSL_CERT

I read something like this

openssl genrsa 2048 > ca-key.pem
openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem > ca-cert.pem

It seems that is what I need to do, could anyone confirm?

Upvotes: 3

Views: 5212

Answers (2)

Ryan Lavelle
Ryan Lavelle

Reputation: 1332

To connect to AWS RDS via SSL in Laravel you only need to do a few things.

Download the rds-combined-ca-bundle.pem file from:

Download pem from the following link: https://www.amazontrust.com/repository/AmazonRootCA1.pem

Then place it in your configuration like this:

'options' => array(    
    PDO::MYSQL_ATTR_SSL_CA => $cert_base . '/AmazonRootCA1.pem'
 ),

Remember to enable SSL/TLS on your RDS instance.

Upvotes: 10

Hassan Shamshir
Hassan Shamshir

Reputation: 123

RDS Proxy and cluster endpoint SSL connection with Laravel 7 application
Download pem from the following link https://www.amazontrust.com/repository/AmazonRootCA1.pem

1. Add the below line of code into your database config php file

 'options' => [
            PDO::MYSQL_ATTR_SSL_CA => base_path('AmazonRootCA1.pem')
        ],

2. I have enabled SSL on RDS Cluster by using the following link
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql-ssl-connections.html#MySQL.Concepts.SSLSupport

3. Enabled Transport Layer Security by updating proxy configuration

Upvotes: 0

Related Questions