2016-12-20 22:16:29 +00:00
|
|
|
'use strict';
|
2017-07-17 22:33:46 +00:00
|
|
|
require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
2016-12-20 22:16:29 +00:00
|
|
|
|
|
|
|
// Check cert chain is received by client, and is completed with the ca cert
|
|
|
|
// known to the client.
|
|
|
|
|
|
|
|
const {
|
|
|
|
assert, connect, debug, keys
|
2017-07-17 22:33:46 +00:00
|
|
|
} = require(fixtures.path('tls-connect'));
|
2016-12-20 22:16:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// agent6-cert.pem includes cert for agent6 and ca3, split it apart and
|
|
|
|
// provide ca3 in the .ca property.
|
2017-02-14 04:29:33 +00:00
|
|
|
const agent6Chain = keys.agent6.cert.split(/(?=-----BEGIN CERTIFICATE-----)/);
|
2016-12-20 22:16:29 +00:00
|
|
|
const agent6End = agent6Chain[0];
|
|
|
|
const agent6Middle = agent6Chain[1];
|
|
|
|
connect({
|
|
|
|
client: {
|
|
|
|
checkServerIdentity: (servername, cert) => { },
|
|
|
|
ca: keys.agent6.ca,
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
cert: agent6End,
|
|
|
|
key: keys.agent6.key,
|
|
|
|
ca: agent6Middle,
|
|
|
|
},
|
|
|
|
}, function(err, pair, cleanup) {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
const peer = pair.client.conn.getPeerCertificate();
|
|
|
|
debug('peer:\n', peer);
|
2023-02-01 19:51:39 +00:00
|
|
|
assert.match(peer.serialNumber, /5B75D77EDC7FB5B7FA9F1424DA4C64FB815DCBDE/i);
|
2016-12-20 22:16:29 +00:00
|
|
|
|
|
|
|
const next = pair.client.conn.getPeerCertificate(true).issuerCertificate;
|
|
|
|
const root = next.issuerCertificate;
|
|
|
|
delete next.issuerCertificate;
|
|
|
|
debug('next:\n', next);
|
2023-02-01 19:51:39 +00:00
|
|
|
assert.match(next.serialNumber, /147D36C1C2F74206DE9FAB5F2226D78ADB00A425/i);
|
2016-12-20 22:16:29 +00:00
|
|
|
|
|
|
|
debug('root:\n', root);
|
2023-02-01 19:51:39 +00:00
|
|
|
assert.match(root.serialNumber, /4AB16C8DFD6A7D0D2DFCABDF9C4B0E92C6AD0229/i);
|
2016-12-20 22:16:29 +00:00
|
|
|
|
|
|
|
return cleanup();
|
|
|
|
});
|