-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable SSL connection #152
Conversation
What about listening port? Is it still 5432 for SSL connections? Also what happens if someone passes |
Yes the port is the same. From http://www.postgresql.org/docs/current/static/ssl-tcp.html
Then it's the switch from I've added support for case-insensitive |
It's now using the default paths for the SSL keys since 9.1 does not allow changing them |
Any news on this? |
I'm +1 on being able to somehow use |
Agree that we should not generate ssl files. I actually got this working with a simple bash script and certs in #!/bin/bash
set -e
# this line is not actually required since "host records match either SSL or non-SSL connection attempts"
#sed -i 's/host/hostssl/g' "$PGDATA"/pg_hba.conf
cp /docker-entrypoint-initdb.d/server.{crt,key} "$PGDATA"
chown postgres:postgres "$PGDATA"/server.{crt,key}
chmod 0600 "$PGDATA"/server.key Then I ran postgres with ssl on ( docker run -it --rm -v $PWD/certs/:/docker-entrypoint-initdb.d/ --name pg postgres -l |
Thanks for the review! I can provide an option to mount the certs as a volume for use in production environments, but I still think a simpler solution would be interesting for development environments. As a developper, I don't want to have or know how to setup SSL certs when working, but I do want to test my app with SSL enabled. Would a batteries included but removable approach work for you here? |
Regarding @yosifkit comment on |
@adrienkohlbecker do you mean another config option for embedded SSL certs? Maybe it'd be better to create ssl certs on startup if non are provided in mounted volume? This will allow developers to just enable dummy certs. On production deployments admins could use specific certificates provided on run time. |
Yes I meant automatically generating certificates if none are mounted.
|
@adrienkohlbecker: Have you thought of using the "snakeoil" certs installed by the "ssl-cert" package?
It seems to be easier using an existing OS-level package to generate the self-signed certificates. |
PR rebased on the latest master.
|
One issue I can think of is with the |
@adrienkohlbecker: well spotted... suggestion below to be run on docker-entrypoint.sh
|
Thanks, added 👍 |
Any updates on this? |
Looking back on my previous comment, I was able to get ssl working with only a 6 line bash script (if you keep the sed that fixes |
Fair enough, I'm closing the PR. |
All `PG*` environment variables can be overridden when using `pg:pull` or `pg:push` since #97, except `PGSSLMODE`, probably because there was no obvious use case to let users decide to insecurely bypass SSL. But when using a PostgreSQL server in Docker Comnpose using the official Postgres image, it's usually hosted on a different container than the user app and can be reached through Docker virtual network, and thus (rightously) considered remote. Unfortunately, the official Postgres image does not support SSL. It seems like a use case where it is safe to bypass SSL, even though the server is considered remote. And it might be a growing use case since even the official Postgres image do not intend to support SSL: docker-library/postgres#152 Thus I'd love to be able to use `pg:pull` from my app container to load a database in a PG server in another container 😍
All `PG*` environment variables can be overridden when using `pg:pull` or `pg:push` since #97, except `PGSSLMODE`, probably because there was no obvious use case to let users decide to insecurely bypass SSL. But when using a PostgreSQL server in Docker Comnpose using the official Postgres image, it's usually hosted on a different container than the user app and can be reached through Docker virtual network, and thus (rightously) considered remote. Unfortunately, the official Postgres image does not support SSL. It seems like a use case where it is safe to bypass SSL, even though the server is considered remote. And it might be a growing use case since even the official Postgres image do not intend to support SSL: docker-library/postgres#152 Thus I'd love to be able to use `pg:pull` from my app container to load a database in a PG server in another container 😍
@yosifkit , sorry for pinging you, however, it looks your script does not work for the latest postgresql image (I don't know if it worked before :-( ) Here's what I do:
My #!/bin/bash
set -e
echo test test
... Log output looks as follows (note:
The problem with SSL keys is PostgreSQL requires the keys to have Do you think yet another set of I guess the culprit is postgres/12/docker-entrypoint.sh Lines 291 to 294 in 16dd8db
|
Hello,
This PR adds a new configuration
$POSTGRES_ENABLE_SSL
which:Best