Skip to content

fix(postgres): only enable SSL when cert and key files actually exist on disk#1197

Open
burnerlee wants to merge 1 commit into
timeplus-io:developfrom
burnerlee:bugfix/issue-824-postgres-port
Open

fix(postgres): only enable SSL when cert and key files actually exist on disk#1197
burnerlee wants to merge 1 commit into
timeplus-io:developfrom
burnerlee:bugfix/issue-824-postgres-port

Conversation

@burnerlee

Copy link
Copy Markdown

PR checklist:

  • Did you run ClangFormat ? Yes (no formatting changes in modified lines)
  • Did you separate headers to a different section in existing community code base ? N/A (no new headers in inherited code)
  • Did you surround proton: starts/ends for new code in existing community code base ? N/A (PostgreSQLHandlerFactory is not ClickHouse-inherited code)

Please write user-readable short description of the changes:

Problem

Connecting to Proton's PostgreSQL port (5432) with psql fails immediately:

psql: error: connection to server at "127.0.0.1", port 5432 failed: SSL SYSCALL error: EOF detected
        connection to server at "127.0.0.1", port 5432 failed: server closed the connection unexpectedly

This happens on any deployment where SSL certificate files are not present (the default).

Root Cause

PostgreSQLHandlerFactory hardcoded ssl_enabled = true at compile time whenever USE_SSL was set. The psql client always sends an SSL_REQUEST first before the startup message. The handler entered makeSecureConnectionSSL(), which called Poco::Net::SSLManager::instance().defaultServerContext() — this throws/fails when no cert/key files are configured, and the connection drops with EOF before any error can be sent back to the client.

Fix

Default ssl_enabled to false. In the factory constructor, read openSSL.server.certificateFile and openSSL.server.privateKeyFile from the server config at runtime. Only set ssl_enabled = true when both keys are non-empty and both files exist on disk.

When ssl_enabled = false, the handler correctly responds 'N' to SSL_REQUEST, and psql falls back to plaintext — the expected behavior for a server without SSL configured.

Fixes #824

… on disk

When USE_SSL is compiled in, ssl_enabled was hardcoded to true regardless
of whether cert/key files were present. psql sends SSL_REQUEST first;
the handler called makeSecureConnectionSSL() which invoked
SSLManager::defaultServerContext() — this fails with no certs configured,
dropping the connection with "SSL SYSCALL error: EOF detected".

Fix: default ssl_enabled to false, check openSSL.server.certificateFile
and openSSL.server.privateKeyFile at runtime in the factory constructor.
Only set ssl_enabled=true when both files exist on disk.

Fixes timeplus-io#824
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@burnerlee burnerlee marked this pull request as draft June 11, 2026 17:11
@burnerlee burnerlee marked this pull request as ready for review June 11, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot connect to postgres port 5432

3 participants