-
-
Save listrophy/45ae8c0241cc739a48c076192adf8f3d to your computer and use it in GitHub Desktop.
Enabling SSL for PostgreSQL in Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu -o pipefail | |
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem | |
openssl rsa -in privkey.pem -passin pass:abcd -out server.key | |
openssl req -x509 -in server.req -text -key server.key -out server.crt | |
chmod og-rwx server.key | |
# insert the following argument if you want to expose a different port for postgres: | |
# -p 5433:5432 \ | |
docker run -d \ | |
--name postgres \ | |
-v $PWD/server.crt:/var/ssl/server.crt \ | |
-v $PWD/server.key:/var/ssl/server.key \ | |
postgres:9-alpine \ | |
-c ssl=on \ | |
-c ssl_ciphers='DEFAULT:!LOW:!EXP:!MD5:@STRENGTH' \ | |
-c ssl_cert_file='/var/ssl/server.crt' \ | |
-c ssl_key_file='/var/ssl/server.key' | |
docker run --rm -it --link postgres postgres:9-alpine psql -h postgres -U postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment