From eccdfd04581d781e6dc4ee2d2e6105c99cce1d11 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 19 Oct 2022 16:51:33 +0200 Subject: [PATCH] tls: add support for ALPN fallback when no ALPN protocol matches --- doc/api/errors.md | 11 ++++ doc/api/tls.md | 8 +++ lib/_tls_wrap.js | 7 +++ lib/internal/errors.js | 3 + src/crypto/crypto_tls.cc | 23 ++++++-- src/env_properties.h | 1 + test/parallel/test-tls-alpn-server-client.js | 60 ++++++++++++++++++++ 7 files changed, 109 insertions(+), 4 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index e1e1b92f654505..0a518d67a34e9a 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2698,6 +2698,17 @@ This error represents a failed test. Additional information about the failure is available via the `cause` property. The `failureType` property specifies what the test was doing when the failure occurred. + + +### `ERR_TLS_ALPN_FALLBACK_WITHOUT_PROTOCOLS` + +This error is thrown when creating a `TLSServer` if the TLS options sets +`allowALPNFallback` to `true` without providing an `ALPNProtocols` argument. + +When `ALPNProtocols` is not provided, ALPN is skipped entirely, so the fallback +would not be functional. To enable ALPN for all protocols, using the fallback +in all cases, set `ALPNProtocols` to an empty array instead. + ### `ERR_TLS_CERT_ALTNAME_FORMAT` diff --git a/doc/api/tls.md b/doc/api/tls.md index a9b23fc97501fc..c98231d1b46baf 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2012,6 +2012,9 @@ where `secureSocket` has the same API as `pair.cleartext`.