• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const fixtures = require('../common/fixtures');
4
5// Check cert chain is received by client, and is completed with the ca cert
6// known to the client.
7
8const {
9  assert, connect, debug, keys
10} = require(fixtures.path('tls-connect'));
11
12
13// agent6-cert.pem includes cert for agent6 and ca3, split it apart and
14// provide ca3 in the .ca property.
15const agent6Chain = keys.agent6.cert.split(/(?=-----BEGIN CERTIFICATE-----)/);
16const agent6End = agent6Chain[0];
17const agent6Middle = agent6Chain[1];
18connect({
19  client: {
20    checkServerIdentity: (servername, cert) => { },
21    ca: keys.agent6.ca,
22  },
23  server: {
24    cert: agent6End,
25    key: keys.agent6.key,
26    ca: agent6Middle,
27  },
28}, function(err, pair, cleanup) {
29  assert.ifError(err);
30
31  const peer = pair.client.conn.getPeerCertificate();
32  debug('peer:\n', peer);
33  assert.strictEqual(peer.serialNumber, 'D0082F458B6EFBE8');
34
35  const next = pair.client.conn.getPeerCertificate(true).issuerCertificate;
36  const root = next.issuerCertificate;
37  delete next.issuerCertificate;
38  debug('next:\n', next);
39  assert.strictEqual(next.serialNumber, 'ECC9B856270DA9A7');
40
41  debug('root:\n', root);
42  assert.strictEqual(root.serialNumber, 'CB153AE212609FC6');
43
44  return cleanup();
45});
46