Closed
Description
I have an issue with enabling of SSL support on postgres docker image. The host is Window 10 machine. The following configuration is used in docker-compose.yml.
version: '3.5'
services:
postgresserver:
image: postgres:14.5
container_name: postgresserver
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: my_password
PGPORT: 5432
command: -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key -c ssl_ca_file=/var/lib/postgresql/CA.pem -c clientcert=verify-ca
volumes:
- "./certs/myCA.pem:/var/lib/postgresql/CA.pem"
- "./certs/postgresserver.internal.crt:/var/lib/postgresql/server.crt"
- "./certs/postgresserver.internal.key:/var/lib/postgresql/server.key"
networks:
default:
aliases:
- postgresserver.internal
openssl:
image: shamelesscookie/openssl:1.1.1
container_name: openssl
stdin_open: true
tty: true
networks:
default:
name: dummy network
driver: bridge
ipam:
config:
- subnet: 172.177.0.0/16
The files server.crt, server.key contain the server certificate and the private key signed by my own CA athorities whose certificate is in CA.pem
I have tried to connect using the pre-installed psql-client from Windows PowerShell on host as follows:
& 'C:\Program Files\PostgreSQL\14\bin\psql.exe' "sslmode=require host=localhost port=5432 dbname=test"
This call have produced the following output:
psql: error: connection to server at "localhost" (::1), port 5432 failed: server does not support SSL, but SSL was required
The call without "sslmode=require" switch works like a charm.
I have also tried to use openssl from openssl container as follows:
openssl s_client -starttls postgres -connect postgresserver:5432
This call has produced the following output:
CONNECTED(00000003)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 1 bytes and written 8 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)