node/test/parallel/test-tls-two-cas-one-string.js
Rich Trott 32f6098eef src,test,tools: modify for more stringent linting
ESLint 2.1.0 is coming. Some lint rules have been tightened.

PR-URL: https://github.com/nodejs/node/pull/5214
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2016-02-18 10:11:26 -08:00

36 lines
945 B
JavaScript

'use strict';
const common = require('../common');
const tls = require('tls');
const fs = require('fs');
const ca1 =
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, 'utf8');
const ca2 =
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, 'utf8');
const cert =
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, 'utf8');
const key =
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, 'utf8');
function test(ca, next) {
const server = tls.createServer({ ca, cert, key }, function(conn) {
this.close();
conn.end();
});
server.addContext('agent3', { ca, cert, key });
const host = common.localhostIPv4;
const port = common.PORT;
server.listen(port, host, function() {
tls.connect({ servername: 'agent3', host, port, ca });
});
server.once('close', next);
}
const array = [ca1, ca2];
const string = ca1 + '\n' + ca2;
test(array, () => test(string, () => {}));