lazy load crypto binding
This commit is contained in:
parent
d89f8dce28
commit
7bd94712a8
20
lib/net.js
20
lib/net.js
@ -47,15 +47,7 @@ var EINPROGRESS = binding.EINPROGRESS;
|
|||||||
var ENOENT = binding.ENOENT;
|
var ENOENT = binding.ENOENT;
|
||||||
var EMFILE = binding.EMFILE;
|
var EMFILE = binding.EMFILE;
|
||||||
var END_OF_FILE = 42;
|
var END_OF_FILE = 42;
|
||||||
|
var SecureContext, SecureStream; // lazy loaded
|
||||||
// Do we have openssl crypto?
|
|
||||||
try {
|
|
||||||
var SecureContext = process.binding('crypto').SecureContext;
|
|
||||||
var SecureStream = process.binding('crypto').SecureStream;
|
|
||||||
var haveCrypto = true;
|
|
||||||
} catch (e) {
|
|
||||||
var haveCrypto = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDLE TIMEOUTS
|
// IDLE TIMEOUTS
|
||||||
//
|
//
|
||||||
@ -544,11 +536,17 @@ function Stream (fd, type) {
|
|||||||
sys.inherits(Stream, events.EventEmitter);
|
sys.inherits(Stream, events.EventEmitter);
|
||||||
exports.Stream = Stream;
|
exports.Stream = Stream;
|
||||||
|
|
||||||
|
|
||||||
Stream.prototype.setSecure = function (credentials) {
|
Stream.prototype.setSecure = function (credentials) {
|
||||||
if (!haveCrypto) {
|
// Do we have openssl crypto?
|
||||||
|
try {
|
||||||
|
SecureContext = process.binding('crypto').SecureContext;
|
||||||
|
SecureStream = process.binding('crypto').SecureStream;
|
||||||
|
} catch (e) {
|
||||||
throw new Error('node.js not compiled with openssl crypto support.');
|
throw new Error('node.js not compiled with openssl crypto support.');
|
||||||
}
|
}
|
||||||
var crypto= require("crypto");
|
|
||||||
|
var crypto = require("crypto");
|
||||||
this.secure = true;
|
this.secure = true;
|
||||||
this.secureEstablished = false;
|
this.secureEstablished = false;
|
||||||
// If no credentials given, create a new one for just this Stream
|
// If no credentials given, create a new one for just this Stream
|
||||||
|
Loading…
x
Reference in New Issue
Block a user