1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) common.skip('missing crypto'); 4 5const assert = require('assert'); 6const tls = require('tls'); 7 8assert(Array.isArray(tls.rootCertificates)); 9assert(tls.rootCertificates.length > 0); 10 11// Getter should return the same object. 12assert.strictEqual(tls.rootCertificates, tls.rootCertificates); 13 14// Array is immutable... 15assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); 16assert.throws(() => tls.rootCertificates.sort(), /TypeError/); 17 18// ...and so is the property. 19assert.throws(() => tls.rootCertificates = 0, /TypeError/); 20 21// Does not contain duplicates. 22assert.strictEqual(tls.rootCertificates.length, 23 new Set(tls.rootCertificates).size); 24 25assert(tls.rootCertificates.every((s) => { 26 return s.startsWith('-----BEGIN CERTIFICATE-----\n'); 27})); 28 29assert(tls.rootCertificates.every((s) => { 30 return s.endsWith('\n-----END CERTIFICATE-----'); 31})); 32