Generating SSL Certificates for PostgreSQL

To enable SSL for PostgreSQL, generating valid SSL certificates is a crucial step. These certificates ensure that the communication between the PostgreSQL server and its clients is encrypted and authenticated. Below are the steps to generate SSL certificates:

Generate a Private Key

Begin by generating a private key for the server. This key will be used to encrypt the data. Use the openssl command:

openssl genrsa -out server.key 2048
chmod 600 server.key

The chmod command ensures that only the server process can access the private key.

Create a Certificate Signing Request (CSR)

The CSR is needed to generate a public certificate. Run the following command:

openssl req -new -key server.key -out server.csr

Fill in the requested details like Common Name (e.g., your VPS’s domain or IP).

Generate the SSL Certificate

You can self-sign the certificate for internal use:

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

This creates a certificate (server.crt) valid for one year.

Set Permissions

Ensure the key and certificate files have appropriate permissions:

chmod 600 server.key server.crt

These certificates are now ready to be used with PostgreSQL.

Share:

More Posts

How to Install Maven on macOS 2025

What you will read?1 Check for Java Installation2 Install Homebrew (If Not Installed)3 Install Maven via Homebrew4 Verify Environment Variables (Optional)5 Create a Sample Maven

How to Use Google SMTP Server

What you will read?1 Step 1: Enable SMTP Access in Gmail2 Step 2: Secure Connection with TLS3 Step 3: Send an Email via SMTP4 Step

how to install wine on RHEL

What you will read?1 Check RHEL version and CPU architecture2 Update system and install base tools3 Verify subscription and enable CodeReady Builder4 Enable EPEL repository5

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments