@@ -31,8 +31,8 @@ const {
31
31
32
32
const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process . binding ( 'constants' ) . crypto ;
33
33
34
- // Lazily loaded
35
- var crypto = null ;
34
+ // Lazily loaded from internal/crypto/util.
35
+ let toBuf = null ;
36
36
37
37
const { internalBinding } = require ( 'internal/bootstrap/loaders' ) ;
38
38
const { SecureContext : NativeSecureContext } = internalBinding ( 'crypto' ) ;
@@ -178,26 +178,26 @@ exports.createSecureContext = function createSecureContext(options, context) {
178
178
}
179
179
180
180
if ( options . pfx ) {
181
- if ( ! crypto )
182
- crypto = require ( 'crypto' ) ;
181
+ if ( ! toBuf )
182
+ toBuf = require ( 'internal/ crypto/util' ) . toBuf ;
183
183
184
184
if ( Array . isArray ( options . pfx ) ) {
185
185
for ( i = 0 ; i < options . pfx . length ; i ++ ) {
186
186
const pfx = options . pfx [ i ] ;
187
187
const raw = pfx . buf ? pfx . buf : pfx ;
188
- const buf = crypto . _toBuf ( raw ) ;
188
+ const buf = toBuf ( raw ) ;
189
189
const passphrase = pfx . passphrase || options . passphrase ;
190
190
if ( passphrase ) {
191
- c . context . loadPKCS12 ( buf , crypto . _toBuf ( passphrase ) ) ;
191
+ c . context . loadPKCS12 ( buf , toBuf ( passphrase ) ) ;
192
192
} else {
193
193
c . context . loadPKCS12 ( buf ) ;
194
194
}
195
195
}
196
196
} else {
197
- const buf = crypto . _toBuf ( options . pfx ) ;
197
+ const buf = toBuf ( options . pfx ) ;
198
198
const passphrase = options . passphrase ;
199
199
if ( passphrase ) {
200
- c . context . loadPKCS12 ( buf , crypto . _toBuf ( passphrase ) ) ;
200
+ c . context . loadPKCS12 ( buf , toBuf ( passphrase ) ) ;
201
201
} else {
202
202
c . context . loadPKCS12 ( buf ) ;
203
203
}
0 commit comments