fix(postgresql): pass SSL client certificates when connecting via host/port (#273) - #284
Merged
Merged
Conversation
…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
force-pushed
the
issue/273-postgres-ssl-host-port
branch
from
July 10, 2026 12:04
ebd85e4 to
33184a0
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 usedsslMode: SslMode.requirewithout the certificates, causing TLS authentication failures.Changes
PostgresConnectionnow storessslRootCert,sslCert,sslKey.fromConnectionRowextracts these parameters fromconnectionStringquery parameters._buildSettings()creates aSecurityContextand loads the certificates when any path is present, then passes the context toConnectionSettings.SecurityContextwhen the parsed URI does not provide one.connectToDatabase()preserves the certificate parameters when switching databases.PostgresConnectionused fortestConnection().connect()in host/port mode.Test plan
flutter test test/core/database/postgres_connection_test.dartpassesflutter test test/features/postgresql/postgresql_connection_form_test.dartpassesCloses
Closes #273