mirror of https://github.com/nodejs/node.git
tls: for...of in _tls_common.js
PR-URL: https://github.com/nodejs/node/pull/30961 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>pull/30999/head
parent
503900b463
commit
7f536f2455
|
@ -100,15 +100,12 @@ exports.createSecureContext = function createSecureContext(options) {
|
|||
|
||||
const c = new SecureContext(options.secureProtocol, secureOptions,
|
||||
options.minVersion, options.maxVersion);
|
||||
let i;
|
||||
let val;
|
||||
|
||||
// Add CA before the cert to be able to load cert's issuer in C++ code.
|
||||
const { ca } = options;
|
||||
if (ca) {
|
||||
if (ArrayIsArray(ca)) {
|
||||
for (i = 0; i < ca.length; ++i) {
|
||||
val = ca[i];
|
||||
for (const val of ca) {
|
||||
validateKeyOrCertOption('ca', val);
|
||||
c.context.addCACert(val);
|
||||
}
|
||||
|
@ -123,8 +120,7 @@ exports.createSecureContext = function createSecureContext(options) {
|
|||
const { cert } = options;
|
||||
if (cert) {
|
||||
if (ArrayIsArray(cert)) {
|
||||
for (i = 0; i < cert.length; ++i) {
|
||||
val = cert[i];
|
||||
for (const val of cert) {
|
||||
validateKeyOrCertOption('cert', val);
|
||||
c.context.setCert(val);
|
||||
}
|
||||
|
@ -142,8 +138,7 @@ exports.createSecureContext = function createSecureContext(options) {
|
|||
const passphrase = options.passphrase;
|
||||
if (key) {
|
||||
if (ArrayIsArray(key)) {
|
||||
for (i = 0; i < key.length; ++i) {
|
||||
val = key[i];
|
||||
for (const val of key) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const pem = (val != undefined && val.pem !== undefined ? val.pem : val);
|
||||
validateKeyOrCertOption('key', pem);
|
||||
|
@ -242,8 +237,8 @@ exports.createSecureContext = function createSecureContext(options) {
|
|||
|
||||
if (options.crl) {
|
||||
if (ArrayIsArray(options.crl)) {
|
||||
for (i = 0; i < options.crl.length; i++) {
|
||||
c.context.addCRL(options.crl[i]);
|
||||
for (const crl of options.crl) {
|
||||
c.context.addCRL(crl);
|
||||
}
|
||||
} else {
|
||||
c.context.addCRL(options.crl);
|
||||
|
@ -259,8 +254,7 @@ exports.createSecureContext = function createSecureContext(options) {
|
|||
toBuf = require('internal/crypto/util').toBuf;
|
||||
|
||||
if (ArrayIsArray(options.pfx)) {
|
||||
for (i = 0; i < options.pfx.length; i++) {
|
||||
const pfx = options.pfx[i];
|
||||
for (const pfx of options.pfx) {
|
||||
const raw = pfx.buf ? pfx.buf : pfx;
|
||||
const buf = toBuf(raw);
|
||||
const passphrase = pfx.passphrase || options.passphrase;
|
||||
|
|
|
@ -465,9 +465,9 @@ function makeMethodProxy(name) {
|
|||
return this._parent[name].apply(this._parent, args);
|
||||
};
|
||||
}
|
||||
for (let n = 0; n < proxiedMethods.length; n++) {
|
||||
tls_wrap.TLSWrap.prototype[proxiedMethods[n]] =
|
||||
makeMethodProxy(proxiedMethods[n]);
|
||||
for (const proxiedMethod of proxiedMethods) {
|
||||
tls_wrap.TLSWrap.prototype[proxiedMethod] =
|
||||
makeMethodProxy(proxiedMethod);
|
||||
}
|
||||
|
||||
tls_wrap.TLSWrap.prototype.close = function close(cb) {
|
||||
|
@ -1303,8 +1303,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(
|
|||
function SNICallback(servername, callback) {
|
||||
const contexts = this.server._contexts;
|
||||
|
||||
for (let i = 0; i < contexts.length; i++) {
|
||||
const elem = contexts[i];
|
||||
for (const elem of contexts) {
|
||||
if (elem[0].test(servername)) {
|
||||
callback(null, elem[1]);
|
||||
return;
|
||||
|
|
|
@ -9,12 +9,11 @@ const {
|
|||
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
|
||||
function parseCertString(s) {
|
||||
const out = ObjectCreate(null);
|
||||
const parts = s.split('\n');
|
||||
for (let i = 0, len = parts.length; i < len; i++) {
|
||||
const sepIndex = parts[i].indexOf('=');
|
||||
for (const part of s.split('\n')) {
|
||||
const sepIndex = part.indexOf('=');
|
||||
if (sepIndex > 0) {
|
||||
const key = parts[i].slice(0, sepIndex);
|
||||
const value = parts[i].slice(sepIndex + 1);
|
||||
const key = part.slice(0, sepIndex);
|
||||
const value = part.slice(sepIndex + 1);
|
||||
if (key in out) {
|
||||
if (!ArrayIsArray(out[key])) {
|
||||
out[key] = [out[key]];
|
||||
|
|
Loading…
Reference in New Issue