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.match(peer.serialNumber, /5B75D77EDC7FB5B7FA9F1424DA4C64FB815DCBDE/i); 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.match(next.serialNumber, /147D36C1C2F74206DE9FAB5F2226D78ADB00A425/i); 40 41 debug('root:\n', root); 42 assert.match(root.serialNumber, /4AB16C8DFD6A7D0D2DFCABDF9C4B0E92C6AD0229/i); 43 44 return cleanup(); 45}); 46