Title: Allow ALPN fallback · Issue #45056 · nodejs/node · GitHub
Open Graph Title: Allow ALPN fallback · Issue #45056 · nodejs/node
X Title: Allow ALPN fallback · Issue #45056 · nodejs/node
Description: What is the problem this feature will solve? I want to create a TLS server that uses ALPN but accepts all protocols from the client. There's all sorts of interesting cases for this, but the simplest is when the server is really a TLS-ter...
Open Graph Description: What is the problem this feature will solve? I want to create a TLS server that uses ALPN but accepts all protocols from the client. There's all sorts of interesting cases for this, but the simples...
X Description: What is the problem this feature will solve? I want to create a TLS server that uses ALPN but accepts all protocols from the client. There's all sorts of interesting cases for this, but the sim...
Opengraph URL: https://github.com/nodejs/node/issues/45056
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow ALPN fallback","articleBody":"### What is the problem this feature will solve?\n\nI want to create a TLS server that uses ALPN but accepts _all_ protocols from the client.\r\n\r\nThere's all sorts of interesting cases for this, but the simplest is when the server is really a TLS-terminating proxy of some kind that's just forwarding data upstream. ALPN is necessary in these cases because some clients (e.g. GRPC) will completely fail to connect to a server that does not explicitly support their protocol of choice. I suspect that'll become even more common in future as ALPN becomes widespread outside HTTP/2.\r\n\r\nMy case is a little more specific: my server is a proxy that supports network debugging, and I specifically want to accept all protocols so that I can capture and debug unexpected traffic, rather than rejecting it at the door. I think this applies more widely though.\n\n### What is the feature you are proposing to solve the problem?\n\nAn additional TLS server option like `allowALPNFallback: \u003cboolean>`.\r\n\r\nIf set, at the end of [the SelectALPNCallback callback](https://github.com/tniessen/node/blob/21958e4eaa6d57f4f6afb766ea2cf3a34d7180db/src/crypto/crypto_tls.cc#L221-L256) if `status == OPENSSL_NPN_NEGOTIATED` then `SSL_TLSEXT_ERR_OK` should be returned instead of `SSL_TLSEXT_ERR_ALERT_FATAL`, thereby accepting the `out` value set by `SSL_select_next_proto` in the lines above.\r\n\r\nI believe this works because the feature described is already the default behaviour of OpenSSL's `SSL_select_next_proto` function, which sets `out` in this callback to the client's first protocol preference by default if no matching server protocol is found. Docs here: https://www.openssl.org/docs/man3.0/man3/SSL_select_next_proto.html. The only reason that this doesn't work already is the additional check the Node adds, which sends an alert and kills the connection instead.\n\n### What alternatives have you considered?\n\nI've opened this because this behaviour was recently changed in Node 19 in https://github.com/nodejs/node/pull/44031. Previously in many cases it was possible to at least detect and in some cases fudge these connections because the connection continued (without an ALPN response but without failure) despite the lack of ALPN protocol agreement. Now it will always be rejected explicitly, which makes this use case more complicated.\r\n\r\nI do agree the new behaviour in #44031 is correct as the default, but I just don't think that the RFC quoted there mandates this strict behaviour for _all_ TLS servers. As quoted in that PR, the RFC says:\r\n\r\n> It is expected that a server will have a list of protocols that it supports, in preference order, and will only select a protocol if the client supports it. In that case, the server SHOULD select the most highly preferred protocol that it supports and that is also advertised by the client. In the event that the server supports no protocols that the client advertises, then the server SHALL respond with a fatal \"no_application_protocol\" alert.\r\n\r\nIn my case, the server effectively supports all protocols (i.e. it doesn't care, it's just proxying raw traffic) and so it's not required to send the alert - it's reasonable to accept the client's preference for unknown protocols.\r\n\r\nA more general alternative would be an ALPN callback, to allow TLS servers to implement arbitrary logic like this or other ways to pick the ALPN protocol from JS directly. Imo that's interesting and all very cool, but not really necessary, and quite a bit more complicated, so probably not worthwhile. Could be worth considering if others see a good use cases for this though.","author":{"url":"https://github.com/pimterry","@type":"Person","name":"pimterry"},"datePublished":"2022-10-18T16:52:28Z","url":"https://github.com/nodejs/node/issues/45056"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b9f5393f-ba93-33f3-ad44-1c1e007c4155 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B45E:9B30C:5FE44A:832AC4:6AED8A90 |
| html-safe-nonce | 39b4680badb97177df459298ea286a84c40367e619c920335ebfab1cdcf951a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDVFOjlCMzBDOjVGRTQ0QTo4MzJBQzQ6NkFFRDhBOTAiLCJ2aXNpdG9yX2lkIjoiODkyNTA5NDI4MjI5MjcyNjQxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f85b835a7d75e08c08f22c81714b58a61670135635605e37cb9d97db1ff20f95 |
| hovercard-subject-tag | issue:1413544489 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/45056/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d80ef28954347002d2779dcb35cf88c08c20a8bbb6314dc9ae13c3a5756937e9/nodejs/node/issues/45056 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d80ef28954347002d2779dcb35cf88c08c20a8bbb6314dc9ae13c3a5756937e9/nodejs/node/issues/45056 |
| og:image:alt | What is the problem this feature will solve? I want to create a TLS server that uses ALPN but accepts all protocols from the client. There's all sorts of interesting cases for this, but the simples... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pimterry |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width