From 33fbf986b5324b83994959bcf13328ea282101c9 Mon Sep 17 00:00:00 2001 From: ofirbarak Date: Wed, 25 May 2022 15:24:28 +0300 Subject: [PATCH] http2: set origin name correctly when servername is empty Fixes: https://github.com/nodejs/node/issues/39919 Refs: https://github.com/nodejs/node/pull/39934 PR-URL: https://github.com/nodejs/node/pull/42838 Reviewed-By: Paolo Insogna Reviewed-By: Rafael Gonzaga Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Matteo Collina --- lib/internal/http2/core.js | 2 +- test/parallel/test-http2-create-client-secure-session.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 661a6d111dee93..2ea9c01cccbf54 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -3111,7 +3111,7 @@ function initializeTLSOptions(options, servername) { options.ALPNProtocols = ['h2']; if (options.allowHTTP1 === true) ArrayPrototypePush(options.ALPNProtocols, 'http/1.1'); - if (servername !== undefined && options.servername === undefined) + if (servername !== undefined && !options.servername) options.servername = servername; return options; } diff --git a/test/parallel/test-http2-create-client-secure-session.js b/test/parallel/test-http2-create-client-secure-session.js index 4303786b3e435d..2f7678cc689825 100644 --- a/test/parallel/test-http2-create-client-secure-session.js +++ b/test/parallel/test-http2-create-client-secure-session.js @@ -91,3 +91,9 @@ verifySecureSession( loadKey('agent1-cert.pem'), loadKey('ca1-cert.pem'), { servername: 'agent1' }); + +verifySecureSession( + loadKey('agent8-key.pem'), + loadKey('agent8-cert.pem'), + loadKey('fake-startcom-root-cert.pem'), + { servername: '' });