From 27b11b8c86390a95249d20c9ee6e1ef037dd3c42 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 26 Oct 2022 14:33:32 +0200 Subject: [PATCH 1/5] tls: add ALPNCallback server option for dynamic ALPN negotiation --- doc/api/errors.md | 14 +++++ doc/api/tls.md | 14 +++++ lib/_tls_wrap.js | 56 +++++++++++++++++ lib/internal/errors.js | 10 +++ src/crypto/crypto_tls.cc | 48 +++++++++++++++ src/crypto/crypto_tls.h | 2 + src/env_properties.h | 1 + test/parallel/test-tls-alpn-server-client.js | 65 +++++++++++++++++++- 8 files changed, 207 insertions(+), 3 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 8a212f3c19f1bc..3e338a4e8f8cd6 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2746,6 +2746,20 @@ 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_CALLBACK_INVALID_RESULT` + +This error is thrown when an `ALPNCallback` returns a value that is not in the +list of ALPN protocols offered by the client. + + + +### `ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS` + +This error is thrown when creating a `TLSServer` if the TLS options include +both `ALPNProtocols` and `ALPNCallback`. These options are mutually exclusive. + ### `ERR_TLS_CERT_ALTNAME_FORMAT` diff --git a/doc/api/tls.md b/doc/api/tls.md index e1f0d28509ae34..00a15c1ed249aa 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2049,6 +2049,9 @@ where `secureSocket` has the same API as `pair.cleartext`.