From fa3d6bedf9b1507bc17265eb9fad70b623247d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 24 Aug 2018 10:36:43 +0200 Subject: [PATCH] tls: use internal API instead of crypto module PR-URL: https://github.com/nodejs/node/pull/22501 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Benjamin Gruenbaum Reviewed-By: Anna Henningsen Reviewed-By: Denys Otrishko --- lib/_tls_common.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 1f56c46dd84e74..12896b294ce1eb 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); }