-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #56187 Fixes: #55994 Refs: #45190 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// This test verifies that http2 server support ALPNCallback option. | ||
|
||
if (!common.hasCrypto) common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const h2 = require('http2'); | ||
const tls = require('tls'); | ||
|
||
{ | ||
// Server sets two incompatible ALPN options: | ||
assert.throws(() => h2.createSecureServer({ | ||
ALPNCallback: () => 'a', | ||
ALPNProtocols: ['b', 'c'] | ||
}), (error) => error.code === 'ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS'); | ||
} | ||
|
||
{ | ||
const server = h2.createSecureServer({ | ||
key: fixtures.readKey('rsa_private.pem'), | ||
cert: fixtures.readKey('rsa_cert.crt'), | ||
ALPNCallback: () => 'a', | ||
}); | ||
|
||
server.on( | ||
'secureConnection', | ||
common.mustCall((socket) => { | ||
assert.strictEqual(socket.alpnProtocol, 'a'); | ||
socket.end(); | ||
server.close(); | ||
}) | ||
); | ||
|
||
server.listen(0, function() { | ||
const client = tls.connect({ | ||
port: server.address().port, | ||
rejectUnauthorized: false, | ||
ALPNProtocols: ['a'], | ||
}, common.mustCall(() => { | ||
assert.strictEqual(client.alpnProtocol, 'a'); | ||
client.end(); | ||
})); | ||
}); | ||
} |