Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions test/parallel/test-tls-multiple-cas-as-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@ const ca2 = fixtures.readKey('ca2-cert.pem', 'utf8');
const cert = fixtures.readKey('agent3-cert.pem', 'utf8');
const key = fixtures.readKey('agent3-key.pem', 'utf8');

function test(ca, next) {
const server = tls.createServer({ ca, cert, key }, function(conn) {
this.close();
conn.end();
});
function test(ca) {
const server = tls.createServer({ ca, cert, key });

server.addContext('agent3', { ca, cert, key });

const host = common.localhostIPv4;
server.listen(0, host, function() {
tls.connect({ servername: 'agent3', host, port: this.address().port, ca });
});

if (next) {
server.once('close', next);
}
server.listen(0, host, common.mustCall(() => {
const socket = tls.connect({
servername: 'agent3',
host,
port: server.address().port,
ca
}, common.mustCall(() => {
socket.end();
}));

socket.on('close', () => {
server.close();
});
}));
}

// `ca1` is not actually necessary for the certificate validation -- maybe
// the fixtures should be written in a way that requires it?
const array = [ca1, ca2];
const string = `${ca1}\n${ca2}`;
test(array, common.mustCall(() => test(string)));
test([ca1, ca2]);
test(`${ca1}\n${ca2}`);