summaryrefslogtreecommitdiff
path: root/lib/_tls_common.js
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2018-04-25 13:58:32 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-04-27 07:12:26 +0200
commite10cb7fdda85bdf3204ae40843d64e56cf07e5a8 (patch)
tree1552353424b09f0e9b379d1d9a01dfb589fe7672 /lib/_tls_common.js
parent9c8395679cb211c99d47246c1c37ae7c4ae40396 (diff)
downloadandroid-node-v8-e10cb7fdda85bdf3204ae40843d64e56cf07e5a8.tar.gz
android-node-v8-e10cb7fdda85bdf3204ae40843d64e56cf07e5a8.tar.bz2
android-node-v8-e10cb7fdda85bdf3204ae40843d64e56cf07e5a8.zip
tls: specify options.name in validateKeyCert
This commit addresses a TODO added by Ruben Bridgewater in commit c6b6c92185316e13738e6fa931fdd5303e381e46 ("lib: always show ERR_INVALID_ARG_TYPE received part") which was to prefix the name of the invalid argument with 'options.'. This commit also switches the order of the parameters to validateKeyCert to be consistent with other validators. PR-URL: https://github.com/nodejs/node/pull/20284 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/_tls_common.js')
-rw-r--r--lib/_tls_common.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index a9fe0d8f06..d8f6afed0b 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -56,11 +56,10 @@ function SecureContext(secureProtocol, secureOptions, context) {
if (secureOptions) this.context.setOptions(secureOptions);
}
-function validateKeyCert(value, type) {
+function validateKeyCert(name, value) {
if (typeof value !== 'string' && !isArrayBufferView(value)) {
throw new ERR_INVALID_ARG_TYPE(
- // TODO(BridgeAR): Change this to `options.${type}`
- type,
+ `options.${name}`,
['string', 'Buffer', 'TypedArray', 'DataView'],
value
);
@@ -100,11 +99,11 @@ exports.createSecureContext = function createSecureContext(options, context) {
if (Array.isArray(ca)) {
for (i = 0; i < ca.length; ++i) {
val = ca[i];
- validateKeyCert(val, 'ca');
+ validateKeyCert('ca', val);
c.context.addCACert(val);
}
} else {
- validateKeyCert(ca, 'ca');
+ validateKeyCert('ca', ca);
c.context.addCACert(ca);
}
} else {
@@ -116,11 +115,11 @@ exports.createSecureContext = function createSecureContext(options, context) {
if (Array.isArray(cert)) {
for (i = 0; i < cert.length; ++i) {
val = cert[i];
- validateKeyCert(val, 'cert');
+ validateKeyCert('cert', val);
c.context.setCert(val);
}
} else {
- validateKeyCert(cert, 'cert');
+ validateKeyCert('cert', cert);
c.context.setCert(cert);
}
}
@@ -137,11 +136,11 @@ exports.createSecureContext = function createSecureContext(options, context) {
val = key[i];
// eslint-disable-next-line eqeqeq
const pem = (val != undefined && val.pem !== undefined ? val.pem : val);
- validateKeyCert(pem, 'key');
+ validateKeyCert('key', pem);
c.context.setKey(pem, val.passphrase || passphrase);
}
} else {
- validateKeyCert(key, 'key');
+ validateKeyCert('key', key);
c.context.setKey(key, passphrase);
}
}