diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2016-12-20 14:16:29 -0800 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2017-01-12 11:10:41 -0800 |
commit | 733c4a813b39fc78c1b8e36f461e4b1251362f4a (patch) | |
tree | b0ea9205f185ef70831df58b9ac29dfe40b2582e /test/parallel/test-tls-cert-chains-in-ca.js | |
parent | f9665280a495d80b7ace32d59ab29b1983f96731 (diff) | |
download | android-node-v8-733c4a813b39fc78c1b8e36f461e4b1251362f4a.tar.gz android-node-v8-733c4a813b39fc78c1b8e36f461e4b1251362f4a.tar.bz2 android-node-v8-733c4a813b39fc78c1b8e36f461e4b1251362f4a.zip |
test: tls cert chain completion scenarios
PR-URL: https://github.com/nodejs/node/pull/10389
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-tls-cert-chains-in-ca.js')
-rw-r--r-- | test/parallel/test-tls-cert-chains-in-ca.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/parallel/test-tls-cert-chains-in-ca.js b/test/parallel/test-tls-cert-chains-in-ca.js new file mode 100644 index 0000000000..69f62c3f72 --- /dev/null +++ b/test/parallel/test-tls-cert-chains-in-ca.js @@ -0,0 +1,46 @@ +'use strict'; +const common = require('../common'); + +// Check cert chain is received by client, and is completed with the ca cert +// known to the client. + +const join = require('path').join; +const { + assert, connect, debug, keys +} = require(join(common.fixturesDir, 'tls-connect'))(); + + +// agent6-cert.pem includes cert for agent6 and ca3, split it apart and +// provide ca3 in the .ca property. +const agent6Chain = keys.agent6.cert.split('-----END CERTIFICATE-----') + .map((c) => { return c + '-----END CERTIFICATE-----'; }); +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); + assert.strictEqual(peer.serialNumber, 'C4CD893EF9A75DCC'); + + const next = pair.client.conn.getPeerCertificate(true).issuerCertificate; + const root = next.issuerCertificate; + delete next.issuerCertificate; + debug('next:\n', next); + assert.strictEqual(next.serialNumber, '9A84ABCFB8A72ABF'); + + debug('root:\n', root); + assert.strictEqual(root.serialNumber, '8DF21C01468AF393'); + + return cleanup(); +}); |