Repository navigation
fix(pg): preserve configured TLS servername - #3828
Open
ritiksahni wants to merge 1 commit into
Open
ritiksahni wants to merge 1 commit into
ritiksahni wants to merge 1 commit into
Conversation
Keep an explicit ssl.servername instead of replacing it with the connection host. Add option-level and real TLS handshake regression coverage for issue brianc#2803.
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.
Fixes issue #2803
When
ssl.servernameis provided,Connection#upgradeToSSLinitially copies it into the options passed totls.connect(). For non-IP connection hosts, pg then unconditionally replaces it with the connection host.This prevents callers from connecting through one hostname while using another hostname for TLS SNI and certificate verification—for example, connecting through an internal proxy while verifying the database's public hostname.
Only derive
servernamefrom the connection host when no non-empty value was supplied. Existing behavior is preserved for connections that do not configure it:hostfor certificate verification;The regression coverage verifies this at two levels:
servername.This continues the earlier fix proposed in #2804 by @gabegorelick and adds the regression coverage requested in that PR.
Validation
node packages/pg/test/unit/connection/ssl-tests.js postgres://make -C packages/pg test-unitcorepack yarn buildcorepack yarn lintAll of the above pass.