|
24 | 24 | const { |
25 | 25 | ArrayIsArray, |
26 | 26 | ArrayPrototypeFilter, |
| 27 | + ArrayPrototypeForEach, |
27 | 28 | ArrayPrototypeJoin, |
28 | 29 | ArrayPrototypePush, |
29 | 30 | ObjectCreate, |
@@ -142,18 +143,18 @@ function processCiphers(ciphers) { |
142 | 143 | return { cipherList, cipherSuites }; |
143 | 144 | } |
144 | 145 |
|
145 | | -function addCACerts(context, ...certs) { |
146 | | - for (const cert of certs) { |
| 146 | +function addCACerts(context, certs) { |
| 147 | + ArrayPrototypeForEach(certs, (cert) => { |
147 | 148 | validateKeyOrCertOption('ca', cert); |
148 | 149 | context.addCACert(cert); |
149 | | - } |
| 150 | + }); |
150 | 151 | } |
151 | 152 |
|
152 | | -function setCerts(context, ...certs) { |
153 | | - for (const cert of certs) { |
| 153 | +function setCerts(context, certs) { |
| 154 | + ArrayPrototypeForEach(certs, (cert) => { |
154 | 155 | validateKeyOrCertOption('cert', cert); |
155 | 156 | context.setCert(cert); |
156 | | - } |
| 157 | + }); |
157 | 158 | } |
158 | 159 |
|
159 | 160 | exports.createSecureContext = function createSecureContext(options) { |
@@ -196,18 +197,18 @@ exports.createSecureContext = function createSecureContext(options) { |
196 | 197 | // change the checks to !== undefined checks. |
197 | 198 | if (ca) { |
198 | 199 | if (ArrayIsArray(ca)) |
199 | | - addCACerts(c.context, ...ca); |
200 | | - else |
201 | 200 | addCACerts(c.context, ca); |
| 201 | + else |
| 202 | + addCACerts(c.context, [ca]); |
202 | 203 | } else { |
203 | 204 | c.context.addRootCerts(); |
204 | 205 | } |
205 | 206 |
|
206 | 207 | if (cert) { |
207 | 208 | if (ArrayIsArray(cert)) |
208 | | - setCerts(c.context, ...cert); |
209 | | - else |
210 | 209 | setCerts(c.context, cert); |
| 210 | + else |
| 211 | + setCerts(c.context, [cert]); |
211 | 212 | } |
212 | 213 |
|
213 | 214 | // Set the key after the cert. |
@@ -318,15 +319,15 @@ exports.createSecureContext = function createSecureContext(options) { |
318 | 319 |
|
319 | 320 | if (pfx !== undefined) { |
320 | 321 | if (ArrayIsArray(pfx)) { |
321 | | - for (const val of pfx) { |
| 322 | + ArrayPrototypeForEach(pfx, (val) => { |
322 | 323 | const raw = val.buf ? val.buf : val; |
323 | 324 | const pass = val.passphrase || passphrase; |
324 | 325 | if (pass !== undefined) { |
325 | 326 | c.context.loadPKCS12(toBuf(raw), toBuf(pass)); |
326 | 327 | } else { |
327 | 328 | c.context.loadPKCS12(toBuf(raw)); |
328 | 329 | } |
329 | | - } |
| 330 | + }); |
330 | 331 | } else if (passphrase) { |
331 | 332 | c.context.loadPKCS12(toBuf(pfx), toBuf(passphrase)); |
332 | 333 | } else { |
|
0 commit comments