1'use strict'; 2const common = require('../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// agent6-cert.pem includes cert for agent6 and ca3 13connect({ 14 client: { 15 checkServerIdentity: (servername, cert) => { }, 16 ca: keys.agent6.ca, 17 }, 18 server: { 19 cert: keys.agent6.cert, 20 key: keys.agent6.key, 21 }, 22}, common.mustSucceed((pair, cleanup) => { 23 const peer = pair.client.conn.getPeerCertificate(); 24 debug('peer:\n', peer); 25 assert.strictEqual(peer.subject.emailAddress, 'adam.lippai@tresorit.com'); 26 assert.strictEqual(peer.subject.CN, 'Ádám Lippai'); 27 assert.strictEqual(peer.issuer.CN, 'ca3'); 28 assert.strictEqual(peer.serialNumber, 'D0082F458B6EFBE8'); 29 30 const next = pair.client.conn.getPeerCertificate(true).issuerCertificate; 31 const root = next.issuerCertificate; 32 delete next.issuerCertificate; 33 debug('next:\n', next); 34 assert.strictEqual(next.subject.CN, 'ca3'); 35 assert.strictEqual(next.issuer.CN, 'ca1'); 36 assert.strictEqual(next.serialNumber, 'ECC9B856270DA9A7'); 37 38 debug('root:\n', root); 39 assert.strictEqual(root.subject.CN, 'ca1'); 40 assert.strictEqual(root.issuer.CN, 'ca1'); 41 assert.strictEqual(root.serialNumber, 'CB153AE212609FC6'); 42 43 // No client cert, so empty object returned. 44 assert.deepStrictEqual(pair.server.conn.getPeerCertificate(), {}); 45 assert.deepStrictEqual(pair.server.conn.getPeerCertificate(true), {}); 46 47 return cleanup(); 48})); 49