-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Fix: Invalid HTTP/2 origin set when servername is empty #39919 #39934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3098,7 +3098,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know it makes sense for http2 but for https the empty string is used to disable the SNI extension. I wonder if the same should be done here. cc: @nodejs/http2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Yeah that makes sense. This PR is based in what the issue poster has expected to be the intended behaviour. If you confirm SNI should be disabled, I would be happy to make these changes. |
||
options.servername = servername; | ||
return options; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
// Ref: https://github.com/nodejs/node/issues/39919 | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
function _verifyOriginSet(session, originString) { | ||
session.once('remoteSettings', () => { | ||
assert.strictEqual(typeof session.originSet, 'object'); | ||
assert.strictEqual(session.originSet.length, 1); | ||
assert.strictEqual(session.originSet[0], originString); | ||
session.close(); | ||
}); | ||
session.once('error', (error) => { | ||
assert.strictEqual(error.code, 'ECONNREFUSED'); | ||
session.close(); | ||
}); | ||
} | ||
|
||
function withServerName() { | ||
const session = http2.connect('https://1.1.1.1', { servername: 'cloudflare-dns.com' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires an external connection. Is it possible to use localhost? See #39011. Edit: This is not a blocker. The test is under |
||
_verifyOriginSet(session, 'https://cloudflare-dns.com'); | ||
} | ||
|
||
function withEmptyServerName() { | ||
const session = http2.connect('https://1.1.1.1', { servername: '' }); | ||
_verifyOriginSet(session, 'https://1.1.1.1'); | ||
} | ||
|
||
function withoutServerName() { | ||
const session = http2.connect('https://1.1.1.1'); | ||
_verifyOriginSet(session, 'https://1.1.1.1'); | ||
} | ||
|
||
withServerName(); | ||
withEmptyServerName(); | ||
withoutServerName(); |
Uh oh!
There was an error while loading. Please reload this page.