Skip to content
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

tls: Add support for ALPN fallback when no ALPN protocol matches #45075

Closed
wants to merge 1 commit into from

Conversation

pimterry
Copy link
Member

Fixes #45056.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Oct 19, 2022
@bnoordhuis
Copy link
Member

This PR conflicts with #44875 (sorry, I thought it'd been merged) and since that PR optimizes the common case and this PR adds an uncommon case, I'm going to have to ask you to rebase on top of that.

I would have asked you to take another approach anyway because w->object()->Get(..) is too slow, it's much more efficient to store it on the C++ side in TLSWrap.

@@ -2042,6 +2045,11 @@ changes:
e.g. `0x05hello0x05world`, where the first byte is the length of the next
protocol name. Passing an array is usually much simpler, e.g.
`['hello', 'world']`. (Protocols should be ordered by their priority.)
* `allowALPNFallback`: {boolean} If `true`, if the `ALPNProtocols` option was
set and the client uses ALPN, but requests only protocols that are not do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awkwardly structured sentence / grammar here.

->Get(env->context(), env->allow_alpn_fallback_string())
.ToLocalChecked()
.As<Boolean>()
->Value();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @bnoordhuis mentions, this is going to be slow. Definitely should avoid uses of ->Get(...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with the JS/C++ interface. What's the preferred way to set a value from the JS TLS wrap such that it's directly accessible here?

If I create a new private field & setter on the C++ wrap, call that from JS in setup, and then read w->allow_alpn_fallback here instead of these calls, is that a) idiomatic and b) sufficiently performant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and yes. :-)

@pimterry
Copy link
Member Author

Happy to do the final rebase & changes here, but I'm going to wait for a conclusion on the the callback question in #45056 (comment) first, since that would invalidate this.

@pimterry
Copy link
Member Author

Conclusion from #45056 & #45190 and related discussion seems to be that #45190 is a good change that's strictly better than this, so I'm going to close this now as no longer unnecessary.

@pimterry pimterry closed this Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow ALPN fallback
4 participants