- 2 Minutes to read
- Print
- DarkLight
- PDF
PostgreSQL SSL Connection
- 2 Minutes to read
- Print
- DarkLight
- PDF
Introduction
Secure Socket Layer (SSL) is a cryptographic protocol used to establish a secure connection between a client and a server over the internet. It ensures that data transmitted between the client and server remains encrypted and protected from unauthorized access.
This document provides step-by-step instructions on how to connect to a PostgreSQL database hosted on Amazon RDS/Aurora and Google Cloud SQL using SSL.
Connecting to Amazon RDS/Aurora
Please ensure that prior to beginning, you have an Amazon Web Services (AWS) account with the appropriate permissions to manage Amazon RDS or Aurora instances.
Step 1: Configure a Parameter Group
To allow SSL connections to your Amazon RDS/Aurora instance, you need to configure the Parameter group associated with the instance.
In the AWS Management Console, navigate to the Amazon RDS/Aurora dashboard.
Click Parameter Groups in the navigation panel.
To modify the RDS instance's parameter group select you database.
To enable SSL connections, you can either create a new parameter group or modify an existing one. Ensure that the parameter group belongs to the PostgreSQL family, and set the following parameter:
Parameter: rds.force_ssl
Value: "1"
By setting this parameter to "1", SSL connections will be enforced.
Navigate to the configuration tab within the PostgreSQL instance database.
Ensure that your database instance parameter group is synchronized with your database. If it is not, access the modify screen, scroll down, and in the additional configuration section, locate and select your database.
Step 2: Download SSL Certificate
To establish an SSL connection to Amazon RDS/Aurora, you need an SSL certificate.
In the AWS Management Console, navigate to the Amazon RDS/Aurora dashboard.
Choose the PostgreSQL instance you wish to work with.
Locate the relevant certificate bundle for your region within the Amazon RDS documentation.
Download the SSL certificate by clicking on the provided link next to it.
Save the downloaded certificate file (e.g., us-east-2-bundle.pem) to a secure location.
Step 3: Connect to PostgreSQL In Rivery using SSL
Now that you have the SSL certificate and the security group is properly configured, you can establish an SSL connection to your Amazon RDS/Aurora PostgreSQL instance.
- Pick a suitable Connection Name.
- Select the SSL Options tab.
- In order to use SSL authentication with Amazon RDS, you need to choose either the "Verify-CA" or "Verify-Full" modes.
- Simply drag and drop the downloaded SSL certificate onto the CA Certification label.
Connecting to Google Cloud SQL
Please ensure that prior to beginning, you have a Google Cloud Platform (GCP) account with the appropriate permissions to manage Cloud SQL instances.
Step 1: Download the Client Certificates
To establish an SSL connection to Google Cloud SQL, you need to download the client certificate.
In the GCP Console, navigate to the SQL instances page.
Select your PostgreSQL instance.
In the left navigation menu, click on Connections.
Click the Security tab.
Select the option Create Client Certificate.
Provide a unique name for the client certificate.
Download the 3 provided files to a secure location.
Please be aware that the psql command provided at the bottom is not necessary and can be disregarded.
Step 2: Connect to PostgreSQL in Rivery using SSL
With the SSL configuration in place and the client certificates downloaded, you can now connect to your Google Cloud SQL PostgreSQL instance using SSL.
- Pick a suitable Connection Name.
- Select the SSL Options tab.
- Choose the SSL mode of your choice.
- Simply drag and drop the downloaded SSL certificate onto the matching labels of your files.