Enabling SSL for PostgreSQL in Docker

This script demonstrates how to enable SSL mode for a PostgreSQL server run in a Docker container using the official image.

psql automatically attempts to connect securely and “SSL connection” should be printed if successful.

This script uses a self-signed certificate for demonstration purposes - if you wish to make a client connection using JDBC you’ll need to use a URL of the form jdbc:postgresql:///postgres?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory.


Mark Woodbridge | 16 August 2017 | CC BY