summaryrefslogtreecommitdiff
path: root/lib/_tls_common.js
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2018-08-24 10:36:43 +0200
committerTobias Nießen <tniessen@tnie.de>2018-08-27 13:35:46 +0200
commitfa3d6bedf9b1507bc17265eb9fad70b623247d85 (patch)
tree77c0c8e5094f4924db30a208ac112755dc5f0f3b /lib/_tls_common.js
parenta081b43919644adcae0491948cd994946f132be7 (diff)
downloadandroid-node-v8-fa3d6bedf9b1507bc17265eb9fad70b623247d85.tar.gz
android-node-v8-fa3d6bedf9b1507bc17265eb9fad70b623247d85.tar.bz2
android-node-v8-fa3d6bedf9b1507bc17265eb9fad70b623247d85.zip
tls: use internal API instead of crypto module
PR-URL: https://github.com/nodejs/node/pull/22501 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Diffstat (limited to 'lib/_tls_common.js')
-rw-r--r--lib/_tls_common.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index 1f56c46dd8..12896b294c 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -31,8 +31,8 @@ const {
const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto;
-// Lazily loaded
-var crypto = null;
+// Lazily loaded from internal/crypto/util.
+let toBuf = null;
const { internalBinding } = require('internal/bootstrap/loaders');
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
@@ -178,26 +178,26 @@ exports.createSecureContext = function createSecureContext(options, context) {
}
if (options.pfx) {
- if (!crypto)
- crypto = require('crypto');
+ if (!toBuf)
+ toBuf = require('internal/crypto/util').toBuf;
if (Array.isArray(options.pfx)) {
for (i = 0; i < options.pfx.length; i++) {
const pfx = options.pfx[i];
const raw = pfx.buf ? pfx.buf : pfx;
- const buf = crypto._toBuf(raw);
+ const buf = toBuf(raw);
const passphrase = pfx.passphrase || options.passphrase;
if (passphrase) {
- c.context.loadPKCS12(buf, crypto._toBuf(passphrase));
+ c.context.loadPKCS12(buf, toBuf(passphrase));
} else {
c.context.loadPKCS12(buf);
}
}
} else {
- const buf = crypto._toBuf(options.pfx);
+ const buf = toBuf(options.pfx);
const passphrase = options.passphrase;
if (passphrase) {
- c.context.loadPKCS12(buf, crypto._toBuf(passphrase));
+ c.context.loadPKCS12(buf, toBuf(passphrase));
} else {
c.context.loadPKCS12(buf);
}