diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2019-05-20 11:09:02 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2019-05-20 11:09:02 +0200 |
commit | f1a3968a01f2d76fff3d1b677aaefc752661c448 (patch) | |
tree | 3d06e9120f577d7a072045f55a6176606d9819e6 /test/parallel/test-tls-root-certificates.js | |
parent | cc7e15f850d2b3773b555ae05157ec73ea627154 (diff) | |
download | android-node-v8-f1a3968a01f2d76fff3d1b677aaefc752661c448.tar.gz android-node-v8-f1a3968a01f2d76fff3d1b677aaefc752661c448.tar.bz2 android-node-v8-f1a3968a01f2d76fff3d1b677aaefc752661c448.zip |
tls: expose built-in root certificates
Fixes: https://github.com/nodejs/node/issues/25824
PR-URL: https://github.com/nodejs/node/pull/26415
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-root-certificates.js')
-rw-r--r-- | test/parallel/test-tls-root-certificates.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/parallel/test-tls-root-certificates.js b/test/parallel/test-tls-root-certificates.js new file mode 100644 index 0000000000..5f7aa418ac --- /dev/null +++ b/test/parallel/test-tls-root-certificates.js @@ -0,0 +1,31 @@ +'use strict'; +const common = require('../common'); +if (!common.hasCrypto) common.skip('missing crypto'); + +const assert = require('assert'); +const tls = require('tls'); + +assert(Array.isArray(tls.rootCertificates)); +assert(tls.rootCertificates.length > 0); + +// Getter should return the same object. +assert.strictEqual(tls.rootCertificates, tls.rootCertificates); + +// Array is immutable... +assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); +assert.throws(() => tls.rootCertificates.sort(), /TypeError/); + +// ...and so is the property. +assert.throws(() => tls.rootCertificates = 0, /TypeError/); + +// Does not contain duplicates. +assert.strictEqual(tls.rootCertificates.length, + new Set(tls.rootCertificates).size); + +assert(tls.rootCertificates.every((s) => { + return s.startsWith('-----BEGIN CERTIFICATE-----\n'); +})); + +assert(tls.rootCertificates.every((s) => { + return s.endsWith('\n-----END CERTIFICATE-----'); +})); |