node/test/parallel/test-tls-socket-constructor-alpn-options-parsing.js
Ben Noordhuis a76f029818
lib,src: remove openssl feature conditionals
Remove compile-time and run-time conditionals for features that
OpenSSL 1.0.0 and 1.0.1 didn't support: ALPN, OCSP and/or SNI.
They are no longer necessary since our baseline is OpenSSL 1.0.2.

PR-URL: https://github.com/nodejs/node/pull/21094
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-08 00:53:37 +02:00

59 lines
1.2 KiB
JavaScript

'use strict';
// Test that TLSSocket can take arrays of strings for ALPNProtocols.
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const tls = require('tls');
new tls.TLSSocket(null, {
ALPNProtocols: ['http/1.1'],
});
const assert = require('assert');
const net = require('net');
const fixtures = require('../common/fixtures');
const key = fixtures.readKey('agent1-key.pem');
const cert = fixtures.readKey('agent1-cert.pem');
const protocols = [];
const server = net.createServer(common.mustCall((s) => {
const tlsSocket = new tls.TLSSocket(s, {
isServer: true,
server,
key,
cert,
ALPNProtocols: ['http/1.1'],
});
tlsSocket.on('secure', common.mustCall(() => {
protocols.push({
alpnProtocol: tlsSocket.alpnProtocol,
});
tlsSocket.end();
}));
}));
server.listen(0, common.mustCall(() => {
const alpnOpts = {
port: server.address().port,
rejectUnauthorized: false,
ALPNProtocols: ['h2', 'http/1.1']
};
tls.connect(alpnOpts, function() {
this.end();
server.close();
assert.deepStrictEqual(protocols, [
{ alpnProtocol: 'http/1.1' },
]);
});
}));