2015-12-01 12:25:14 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2016-05-30 01:45:20 +02:00
|
|
|
if (!common.hasCrypto) {
|
|
|
|
common.skip('missing crypto');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-01 12:25:14 +01:00
|
|
|
const tls = require('tls');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const ca1 =
|
2016-02-15 16:46:58 +01:00
|
|
|
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, 'utf8');
|
2015-12-01 12:25:14 +01:00
|
|
|
const ca2 =
|
2016-02-15 16:46:58 +01:00
|
|
|
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, 'utf8');
|
2015-12-01 12:25:14 +01:00
|
|
|
const cert =
|
2016-02-15 16:46:58 +01:00
|
|
|
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, 'utf8');
|
2015-12-01 12:25:14 +01:00
|
|
|
const key =
|
2016-02-15 16:46:58 +01:00
|
|
|
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, 'utf8');
|
2015-12-01 12:25:14 +01:00
|
|
|
|
|
|
|
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;
|
2016-05-29 09:06:56 +02:00
|
|
|
server.listen(0, host, function() {
|
|
|
|
tls.connect({ servername: 'agent3', host, port: this.address().port, ca });
|
2015-12-01 12:25:14 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
server.once('close', next);
|
|
|
|
}
|
|
|
|
|
|
|
|
const array = [ca1, ca2];
|
|
|
|
const string = ca1 + '\n' + ca2;
|
|
|
|
test(array, () => test(string, () => {}));
|