---
title: How to Establish a Secure Connection (SSL) from a Node.js API to an AWS RDS
description: Learn at the next post how to establish a secure connection (SSL) from a Node.js API to an AWS RDS and meet all the HIPAA requirements.
---

[Welcome to the Nexton Blog | Nexton](https://blog.nexton.dev)

# [How to Establish a Secure Connection (SSL) from a Node.js API to an AWS RDS](https://blog.nexton.dev/how-to-establish-a-secure-connection-ssl-from-a-node.js-api-to-an-aws-rds)

 Written by [Fabricio Pautasso](https://blog.nexton.dev/author/fabricio-pautasso) | Oct 7, 2020, 6:01:00 PM

One of the requirements to be **HIPAA** compliant is to ensure that all the communication between the application components is performed in a secure manner.

The backend application that needed to be HIPPA compliant was composed of:

- A Node.js API running in a Docker container within an AWS EC2 machine
- An Elastic Load Balancer that was exposing the API over HTTPS
- An RDS Database that the API was using

The communication between the ELB and the API was being done over HTTPS. But the API was accessing the database over HTTP.

<https://images.ctfassets.net/k4d8pgyc7rbq/2zWOxEPxfZxclIkomEHbMy/61caaa02cccbee953280fc396fb60566/docker-node.jpg>

## Problem

> We need to ensure that all application components are using encryption for communication between them

## Solution

We can establish an **SSL** connection with each **RDS** database type( Amazon Aurora, MySQL, PostgreSQL, etc). In this guide, we will show the steps to connect over **SSL** to a **PostgreSQL RDS DB** from a **Node.js** application running on **EC2**.

SSL support is available in all AWS regions for PostgreSQL. Amazon RDS creates an SSL certificate for your PostgreSQL DB instance when the instance is created. If we enable SSL certificate verification, then the SSL certificate includes the DB instance endpoint as the Common Name (CN) for the SSL certificate to guard against spoofing attacks.

To configure our Node.js application to communicate using SSL with the RDS DB we followed the next steps:

1. We downloaded the root cert from [https://s3.amazonaws.com/rds-downloads/rds-ca-2015-root.pem](https://s3.amazonaws.com/rds-downloads/rds-ca-2015-root.pem).
2. We saved it in one of our application directories, for example, /src/config/certs/rds-ca-2015-root.pem
3. We configured our ORM, in our case typeorm, to connect over SSL

<https://images.ctfassets.net/k4d8pgyc7rbq/3Mkk3JZWYO0odi7UFo2dlr/dbdbdd0b86cfa4ec2337c1806fd0301f/code-block-01.png>

1. Application testing

## Connect with DB Tool over SSL

In case we want to query some data from our database directly, we need to connect to it over SSL too. To do that, we used DBeaver using the next networking configuration

<https://images.ctfassets.net/k4d8pgyc7rbq/3JnWYDYmD2EmAFdNjQoq3Q/c3de49b40b8e8f665a8f3a7fcbeef4c2/db-ssl.png>

 

<https://talent.nextonlabs.com/nail-your-interview-with-a-us-company>

 

[View full post](https://blog.nexton.dev/how-to-establish-a-secure-connection-ssl-from-a-node.js-api-to-an-aws-rds)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Fabricio Pautasso"
  },
  "dateModified" : "2022-09-27T14:19:02.202Z",
  "datePublished" : "2020-10-07T18:01:00Z",
  "headline" : "How to Establish a Secure Connection (SSL) from a Node.js API to an AWS RDS",
  "image" : {
    "@type" : "ImageObject",
    "height" : 1013,
    "url" : "https://f.hubspotusercontent20.net/hubfs/14573977/Nxt%20Blog%20-%20how%20to%20establish%20a%20secure.png",
    "width" : 2160
  },
  "mainEntityOfPage" : "https://blog.nexton.dev/how-to-establish-a-secure-connection-ssl-from-a-node.js-api-to-an-aws-rds",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Nexton's blog"
  }
}
```