From 504d1d7bdc6823255bb7958d00af409e0be1996c Mon Sep 17 00:00:00 2001 From: Tim Perry <1526883+pimterry@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:30:30 +0100 Subject: [PATCH] tls: add ALPNCallback server option for dynamic ALPN negotiation PR-URL: https://github.com/nodejs/node/pull/45190 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Debadree Chatterjee --- doc/api/errors.md | 14 ++++ doc/api/tls.md | 14 ++++ lib/_tls_wrap.js | 59 +++++++++++++++ lib/internal/errors.js | 10 +++ src/crypto/crypto_tls.cc | 49 +++++++++++++ src/crypto/crypto_tls.h | 2 + src/env_properties.h | 1 + test/parallel/test-tls-alpn-server-client.js | 75 +++++++++++++++++++- 8 files changed, 221 insertions(+), 3 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index e982a7fb7307c4..5a8637a0ecc8b0 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2729,6 +2729,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 7ac626cb49706c..b1088c115e2ac0 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2047,6 +2047,9 @@ where `secureSocket` has the same API as `pair.cleartext`.