1 | initial version |
To configure SSL in PostgreSQL, follow these steps:
Note: These parameters will point to the SSL certificate files you have created for PostgreSQL. You may need to replace the filepaths with your own server configuration.
Restart the PostgreSQL server for these changes to take effect.
Create an SSL user for PostgreSQL with the following command: CREATE USER ssluser WITH PASSWORD 'password' SSL;
To test the SSL connection, connect to PostgreSQL with the ssluser and specify the SSL mode with the following command: psql -h hostname -U ssluser -d dbname -p port -W sslmode=require
Note: Replace the hostname, dbname and port with your PostgreSQL server configuration. You will be prompted for the ssluser's password.
If the SSL connection is successful, you should see a message indicating that the SSL connection was established.
Finally, revoke the privileges of the SSL user to prevent it from accessing PostgreSQL without SSL: REVOKE CONNECT ON DATABASE dbname FROM PUBLIC; REVOKE SELECT ON pgcatalog.pgstat_ssl FROM PUBLIC;
Note: Replace dbname with the name of your PostgreSQL database.
That's it! You have successfully configured SSL in PostgreSQL.