Skip to content

fix(postgresql): pass SSL client certificates when connecting via host/port (#273) - #284

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/273-postgres-ssl-host-port
Jul 10, 2026
Merged

fix(postgresql): pass SSL client certificates when connecting via host/port (#273)#284
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/273-postgres-ssl-host-port

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

Fixes #273. When a PostgreSQL connection was configured through individual Host/Port fields and SSL client certificates were selected, the certificate paths were saved but never loaded into a SecurityContext. The connection used sslMode: SslMode.require without the certificates, causing TLS authentication failures.

Changes

  • PostgresConnection now stores sslRootCert, sslCert, sslKey.
  • fromConnectionRow extracts these parameters from connectionString query parameters.
  • _buildSettings() creates a SecurityContext and loads the certificates when any path is present, then passes the context to ConnectionSettings.
  • URI-based connections fall back to the extracted SecurityContext when the parsed URI does not provide one.
  • connectToDatabase() preserves the certificate parameters when switching databases.
  • The PostgreSQL connection form passes the certificate paths to the temporary PostgresConnection used for testConnection().
  • Added tests for extraction, preservation, and actual use during connect() in host/port mode.

Test plan

  • flutter test test/core/database/postgres_connection_test.dart passes
  • flutter test test/features/postgresql/postgresql_connection_form_test.dart passes

Closes

Closes #273

@github-actions github-actions Bot added bug Something isn't working core Core library logic and services labels Jul 10, 2026
…t/port (#273)

- Add sslRootCert, sslCert, sslKey fields to PostgresConnection and
  extract them from connectionString query parameters in fromConnectionRow.
- Build a SecurityContext in _buildSettings() when any certificate path is
  present and pass it to ConnectionSettings.
- For URI-based connections, fall back to the extracted SecurityContext when
  the parsed URI does not provide one.
- Forward SSL certificate parameters in connectToDatabase() so database-switch
  connections keep the same certs.
- Pass the certificate paths from the form to the temporary PostgresConnection
  used for testConnection().
- Add tests covering extraction, preservation, and actual use during connect()
  for host/port mode.
@ZhuchkaTriplesix
ZhuchkaTriplesix force-pushed the issue/273-postgres-ssl-host-port branch from ebd85e4 to 33184a0 Compare July 10, 2026 12:04
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 72fecf6 into dev Jul 10, 2026
4 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/273-postgres-ssl-host-port branch July 10, 2026 12:07
@ZhuchkaTriplesix ZhuchkaTriplesix self-assigned this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Core library logic and services

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant