Skip to content

Commit 05ca1a4

Browse files
committed
quic: fix bug in setSNIContexts that lost ALPN config
1 parent 4840926 commit 05ca1a4

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎lib/internal/quic/quic.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4449,6 +4449,8 @@ class QuicEndpoint {
44494449
truncatedReads: undefined,
44504450
onsession: undefined,
44514451
sessionCallbacks: undefined,
4452+
// The encoded ALPN this endpoint listens with.
4453+
alpn: undefined,
44524454
};
44534455

44544456
static {
@@ -4757,6 +4759,7 @@ class QuicEndpoint {
47574759
} = options;
47584760

47594761
inner.truncatedReads = truncatedReads;
4762+
inner.alpn = rest.tls.alpn;
47604763

47614764
// Store session and stream callbacks to apply to each new incoming session.
47624765
inner.sessionCallbacks = {
@@ -4964,7 +4967,8 @@ class QuicEndpoint {
49644967
if (identity.certs === undefined) {
49654968
throw new ERR_MISSING_ARGS(`entries['${hostname}'].certs`);
49664969
}
4967-
processed[hostname] = identity;
4970+
// These identities offer the same protocols as the ones given to listen():
4971+
processed[hostname] = { __proto__: null, ...identity, alpn: this.#inner.alpn };
49684972
}
49694973

49704974
this.#handle.setSNIContexts(processed, replace);

‎test/parallel/test-quic-sni-setcontexts.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ const serverEndpoint = await listen(mustCall(async (serverSession) => {
4848
}
4949

5050
endpoint.setSNIContexts(
51-
{ '*': { keys: [key2], certs: [cert2] } },
51+
{
52+
'*': { keys: [key2], certs: [cert2] },
53+
'localhost': { keys: [key2], certs: [cert2] },
54+
},
5255
{ replace: true },
5356
);
5457

0 commit comments

Comments
 (0)