You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While executing the command PGSSLMODE=disable psql -h localhost -p 2345 -U <username> <databasename>
The pgagroal successfully do the SSL handshake.
Then pgagroal sends the StartUpMessage to postgres
Now in server_passthrough we are passing the authentication request messages between client and postgres.
But while exchanging messages in server_passthrough, we are writing and reading from postgres file descriptor with ssl=NULL (which is an issue since our ssl handshake was successfull and all subsequent messages after ssl handshake must be SSL-encrypted)
So, on writing/reading anything from postgres file descriptor, the postgres server terminates/resets connection.
Logs of postgres (after pgagroal read/write to postgres server in server_passthrough)
2024-09-11 00:27:29.702 IST [187451] ashu3103@test LOG: SSL error: wrong version number
2024-09-11 00:27:29.702 IST [187451] ashu3103@test LOG: could not receive data from client: Connection reset by peer
The current security.c file (where the )
...
2218: status = pgagroal_write_message(NULL, server_fd, msg);
2219: if (status != MESSAGE_STATUS_OK)
2220: {
2221: goto error;
2222: }
2223: pgagroal_free_message(msg);
2224:
2225: status = pgagroal_read_block_message(NULL, server_fd, &msg);
...
Proposed Solution
Pass server ssl context to server_passthrough
Pass server_ssl to every single write/read to postgres
...
2218: status = pgagroal_write_message(server_ssl, server_fd, msg);
2219: if (status != MESSAGE_STATUS_OK)
2220: {
2221: goto error;
2222: }
2223: pgagroal_free_message(msg);
2224:
2225: status = pgagroal_read_block_message(server_ssl, server_fd, &msg);
...
Background
Trying to connect to postgres using tls (disabling ssl from
client
-pgagroal
), focusing on tls ofpgagroal
-postgres
.Setup
pgagroal setup
pgagroal.conf
pgagroal_hba.conf
postgres setup
pg_hba.conf
All connection must do ssl!
postgresql.conf
Issue
While executing the command
PGSSLMODE=disable psql -h localhost -p 2345 -U <username> <databasename>
pgagroal
successfully do the SSL handshake.pgagroal
sends the StartUpMessage to postgresserver_passthrough
we are passing the authentication request messages between client and postgres.server_passthrough
, we are writing and reading from postgres file descriptor with ssl=NULL (which is an issue since our ssl handshake was successfull and all subsequent messages after ssl handshake must be SSL-encrypted)So, on writing/reading anything from postgres file descriptor, the postgres server terminates/resets connection.
Logs of postgres (after pgagroal read/write to postgres server in
server_passthrough
)The current
security.c
file (where the )Proposed Solution
server_passthrough
@jesperpedersen @fluca1978
The text was updated successfully, but these errors were encountered: