Score:0

Using podman/docker secrets to enable SSL for Postgres 15

co flag

I am trying to use podman/docker secrets for ssl certificates but i keep getting SSL errors.

Here is the command i am using:

podman run \
  --detach \
  --restart on-failure:5 \
  --network some_network \
  --name postgres \
  --hostname postgres \
  --publish 5432:5432 \
  --mount type=volume,src=postgres,dst=/var/lib/postgresql/data \
  --secret SUPERUSER \
  --secret SUPERPASS \
  --secret server_key,mode=0600,target=/etc/ssl/server.key \
  --secret server_crt,mode=0600,target=/etc/ssl/server.crt \
  --env POSTGRES_USER_FILE=/run/secrets/SUPERUSER \
  --env POSTGRES_PASSWORD_FILE=/run/secrets/SUPERPASS \
  --env POSTGRES_DB=somedb\
  postgres:15 \
  -c ssl=on \
  -c ssl_cert_file=/etc/ssl/server.crt \
  -c ssl_key_file=/etc/ssl/server.key

and the log:

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-08-29 15:13:42.751 UTC [1] FATAL:  could not load server certificate file "/etc/ssl/server.crt": SSL error code 2147483661
2023-08-29 15:13:42.751 UTC [1] LOG:  database system is shut down

I checked the container that the certificates are actually there and they are and are readable. I also tried running with --privileged flag in case SELinux is to blame but makes little difference.

All and any help is much appreciated! :)

Adding the commands to generate the cert and key as well:

openssl req -new -nodes -text -out root.csr -keyout root.key -subj "/CN=root.yourdomain.com" 
chmod og-rwx root.key 
openssl x509 -req -in root.csr -text -days 3650 -extfile /etc/ssl/openssl.cnf -extensions v3_ca -signkey root.key -out root.crt 
openssl req -new -nodes -text -out server.csr -keyout server.key -subj "/CN=dbhost.yourdomain.com" 
chmod og-rwx server.key 
openssl x509 -req -in server.csr -text -days 365 -CA root.crt -CAkey root.key -CAcreateserial -out server.crt

cat server.key | podman secret create server_key -
cat server.crt | podman secret create server_crt -
in flag
Does it work if you add `,uid=999,gid=999` to the __--secret__ option? uid=999 was found [here](https://github.com/docker-library/postgres/blob/2f0ed0c7e8f8b05b294740f150397eec0af8dc50/15/bookworm/Dockerfile#L13)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.