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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SCRAM-SHA-256-PLUS i.e. channel binding #3356
base: master
Are you sure you want to change the base?
Add support for SCRAM-SHA-256-PLUS i.e. channel binding #3356
Changes from 1 commit
65e1c72
a338521
8ab2b17
37f9285
ae6ab3f
152396f
f899f8f
52e656c
1003bff
50ee305
b3a8757
67a6e9c
b604068
88cbe49
05690bb
d9fdccf
9a91cb7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check failure on line 272 in packages/pg/lib/client.js
GitHub Actions / lint
Check failure on line 3 in packages/pg/lib/crypto/sasl.js
GitHub Actions / lint
Check failure on line 7 in packages/pg/lib/crypto/sasl.js
GitHub Actions / lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a separate package, could
stream.getPeerCertificate().fingerprint256
be used with a fixed selection of SHA-256? Or is that not the same hash?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind – that wouldn’t be spec-compliant and I missed that the
hash
wasn’t being used for anything more than its name anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do appreciate that bringing in a whole X509 parsing library (and then parsing the whole certificate, when all we actually need is the signature algorithm) feels like overkill.
I did actually have a go at doing the minimum necessary parsing manually: see https://gist.github.com/jawj/04a90e51196ac054d6741c8d079d9cff
The reason I didn't go with that in the PR is that I haven't been able to find a list of either (a) what signature algorithms could theoretically be used or even (b) what signature algorithms would cover 99% of cases.
But I strongly suspect that the cases covered by this code would be almost all of them, and any missing ones might be plugged if people filed issues about them. So this could be another option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am absolutely totally down w/ the "make it mostly work and patch if different algorithms show up later" mode if it removes the requirement to pull in an entire dependency! I wouldn't say it's a mandatory change but certainly would be welcome. 😄 I have tried very hard over the years to keep as many 3rd party dependencies out of the code as possible just because....well...left-pad and all that stuff, ya know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brianc Good to hear: I'm all for that approach. I've done a bit more work on this code (including putting a base64 hash of the public cert in the error message, to make it easy to report failures in a way we can investigate) and removed the dependency.
Check failure on line 82 in packages/pg/lib/crypto/sasl.js
GitHub Actions / lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests would work just as well if there were no implementation of channel binding at all, so this PR probably needs a targeted test from someone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in an ideal world we would test using SSL certs with a variety of different signature algorithms. But I'm not sure how easily that fits with the current test setup.
Locally, I have been using:
The
server-*-cert.pem
files from the OpenSSL tests: https://github.com/openssl/openssl/tree/master/test/certsThis Docker file:
Which is run like:
./docker-pg.sh ecdsa
SCRAM_TEST_PGDATABASE=frodo \ SCRAM_TEST_PGUSER=frodo \ SCRAM_TEST_PGPASSWORD=friend \ PGSSLMODE=no-verify \ node --tls-keylog=/path/to/keylog.txt packages/pg/test/integration/client/sasl-scram-tests.js
(The
--tls-keylog
enables the use of Wireshark if needed).