Skip to content

Commit ca63d86

Browse files
committed
quic: fix bug in setSNIContexts that lost ALPN config
1 parent c1d4200 commit ca63d86

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
@@ -4515,6 +4515,8 @@ class QuicEndpoint {
45154515
truncatedReads: undefined,
45164516
onsession: undefined,
45174517
sessionCallbacks: undefined,
4518+
// The encoded ALPN this endpoint listens with.
4519+
alpn: undefined,
45184520
};
45194521

45204522
static {
@@ -4823,6 +4825,7 @@ class QuicEndpoint {
48234825
} = options;
48244826

48254827
inner.truncatedReads = truncatedReads;
4828+
inner.alpn = rest.tls.alpn;
48264829

48274830
// Store session and stream callbacks to apply to each new incoming session.
48284831
inner.sessionCallbacks = {
@@ -5030,7 +5033,8 @@ class QuicEndpoint {
50305033
if (identity.certs === undefined) {
50315034
throw new ERR_MISSING_ARGS(`entries['${hostname}'].certs`);
50325035
}
5033-
processed[hostname] = identity;
5036+
// These identities offer the same protocols as the ones given to listen():
5037+
processed[hostname] = { __proto__: null, ...identity, alpn: this.#inner.alpn };
50345038
}
50355039

50365040
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)