18 lines
850 B
Bash
18 lines
850 B
Bash
#!/bin/sh
|
|
set -eu
|
|
# Copy the mounted TLS material into a private, postgres-owned directory with
|
|
# 0600 permissions: PostgreSQL refuses to load a key that group/other can read,
|
|
# and Docker secrets are mounted world-readable.
|
|
TLS_DIR=/var/lib/postgresql/tls
|
|
install -d -m 700 -o postgres -g postgres "$TLS_DIR"
|
|
install -m 600 -o postgres -g postgres /run/secrets/postgres.crt "$TLS_DIR/server.crt"
|
|
install -m 600 -o postgres -g postgres /run/secrets/postgres.key "$TLS_DIR/server.key"
|
|
install -m 600 -o postgres -g postgres /run/secrets/ca.crt "$TLS_DIR/ca.crt"
|
|
# Clients verify the server certificate (verify-full) against the project CA.
|
|
exec docker-entrypoint.sh postgres \
|
|
-c ssl=on \
|
|
-c ssl_cert_file="$TLS_DIR/server.crt" \
|
|
-c ssl_key_file="$TLS_DIR/server.key" \
|
|
-c ssl_ca_file="$TLS_DIR/ca.crt" \
|
|
-c ssl_min_protocol_version=TLSv1.2
|