Skip to content

fix(postgres): read SSL config from nested DBeaver JSON properties#21

Open
hongweihao wants to merge 1 commit intosrthkdev:mainfrom
hongweihao:fix/postgres-ssl-nested-properties
Open

fix(postgres): read SSL config from nested DBeaver JSON properties#21
hongweihao wants to merge 1 commit intosrthkdev:mainfrom
hongweihao:fix/postgres-ssl-nested-properties

Conversation

@hongweihao
Copy link
Copy Markdown

Problem

When using DBeaver's modern JSON config format (v21+), PostgreSQL connections configured with SSL fail with:

no pg_hba.conf entry for host "...", user "...", database "...", no encryption

even though SSL is correctly configured in DBeaver.

Root Cause

DBeaver's JSON config format stores driver-level properties under a nested properties key and the SSL handler config under handlers.postgre_ssl, rather than at the top level of the connection properties object:

{
  "configuration": {
    "url": "jdbc:postgresql://host:5432/mydb",
    "properties": {
      "sslmode": "require",
      "ssl": "true"
    },
    "handlers": {
      "postgre_ssl": {
        "enabled": true,
        "properties": { "sslMode": "require" }
      }
    }
  }
}

Both getPostgresSslConfig (in connection-pool.ts) and executePostgreSQLQuery (in dbeaver-client.ts) only read from the top-level properties.sslmode / properties.ssl, which are always undefined in this format. As a result, SSL mode falls back to the default or is treated as disabled, and the connection is sent without encryption — causing servers that require SSL (e.g. AWS RDS with hostssl in pg_hba.conf) to reject it.

Fix

Both SSL-reading locations now also check:

  • properties.properties.sslmode / properties.properties.ssl — nested driver props
  • properties.handlers.postgre_ssl.enabled + properties.handlers.postgre_ssl.properties.sslMode — DBeaver's SSL handler block

Testing

Verified against an AWS RDS PostgreSQL 15 instance configured with hostssl in pg_hba.conf. Before this fix, test_connection returned "no encryption" error. After the fix, the connection succeeds with SSL.

🤖 Generated with Claude Code

DBeaver's JSON config format (v21+) stores driver-level properties under
a nested `properties` key and SSL handler config under `handlers.postgre_ssl`,
rather than at the top level of the connection properties object.

Previously, `getPostgresSslConfig` and `executePostgreSQLQuery` only read
from the top-level `properties.sslmode` / `properties.ssl` fields, which
are always undefined in the new format. This caused the SSL mode to fall
back to the default or be treated as disabled, resulting in unencrypted
connections that are rejected by servers requiring SSL (e.g. AWS RDS with
`hostssl` pg_hba.conf rules).

Fix by also checking:
- `properties.properties.sslmode` / `properties.properties.ssl` (nested driver props)
- `properties.handlers.postgre_ssl.enabled` + `properties.handlers.postgre_ssl.properties.sslMode`
  (DBeaver's SSL handler block)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant