@@ -45,6 +45,7 @@ const {
4545 getBundledRootCertificates,
4646 getExtraCACertificates,
4747 // getOpenSSLCACertificates,
48+ getOpenSSLDefaultCACertificates,
4849 lookupOpenSSLCACertificates,
4950 getSystemCACertificates,
5051 resetRootCertStore,
@@ -158,6 +159,14 @@ function cacheSystemCACertificates() {
158159// return opensslCACertificates;
159160// }
160161
162+ let opensslDefaultCACertificates ;
163+ function cacheOpenSSLDefaultCACertificates ( ) {
164+ opensslDefaultCACertificates ||= ObjectFreeze (
165+ getOpenSSLDefaultCACertificates ( ) ) ;
166+
167+ return opensslDefaultCACertificates ;
168+ }
169+
161170let opensslCACertificateLookup ;
162171function cacheOpenSSLCertificateLookup ( subjectNameOrCert ) {
163172 opensslCACertificateLookup ??= new SafeMap ( ) ;
@@ -191,15 +200,19 @@ function cacheDefaultCACertificates() {
191200
192201 defaultCACertificates = [ ] ;
193202
194- if ( ! getOptionValue ( '--use-openssl-ca' ) ) {
203+ if ( getOptionValue ( '--use-openssl-ca' ) ) {
204+ const openssl = cacheOpenSSLDefaultCACertificates ( ) ;
205+ for ( let i = 0 ; i < openssl . length ; ++ i ) {
206+ ArrayPrototypePush ( defaultCACertificates , openssl [ i ] ) ;
207+ }
208+ } else {
195209 const bundled = cacheBundledRootCertificates ( ) ;
196210 for ( let i = 0 ; i < bundled . length ; ++ i ) {
197211 ArrayPrototypePush ( defaultCACertificates , bundled [ i ] ) ;
198212 }
199213 if ( getOptionValue ( '--use-system-ca' ) ) {
200214 const system = cacheSystemCACertificates ( ) ;
201215 for ( let i = 0 ; i < system . length ; ++ i ) {
202-
203216 ArrayPrototypePush ( defaultCACertificates , system [ i ] ) ;
204217 }
205218 }
@@ -208,7 +221,6 @@ function cacheDefaultCACertificates() {
208221 if ( process . env . NODE_EXTRA_CA_CERTS ) {
209222 const extra = cacheExtraCACertificates ( ) ;
210223 for ( let i = 0 ; i < extra . length ; ++ i ) {
211-
212224 ArrayPrototypePush ( defaultCACertificates , extra [ i ] ) ;
213225 }
214226 }
@@ -284,6 +296,7 @@ if (isBuildingSnapshot()) {
284296 extraCACertificates = undefined ;
285297 systemCACertificates = undefined ;
286298 // opensslCACertificates = undefined;
299+ opensslDefaultCACertificates = undefined ;
287300 opensslCACertificateLookup = undefined ;
288301 if ( hasResetDefaultCACertificates ) {
289302 defaultCACertificates = undefined ;
0 commit comments