Browse Source

lazy load crypto binding

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
7bd94712a8
  1. 18
      lib/net.js

18
lib/net.js

@ -47,15 +47,7 @@ var EINPROGRESS = binding.EINPROGRESS;
var ENOENT = binding.ENOENT;
var EMFILE = binding.EMFILE;
var END_OF_FILE = 42;
// 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;
}
var SecureContext, SecureStream; // lazy loaded
// IDLE TIMEOUTS
//
@ -544,10 +536,16 @@ function Stream (fd, type) {
sys.inherits(Stream, events.EventEmitter);
exports.Stream = Stream;
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.');
}
var crypto = require("crypto");
this.secure = true;
this.secureEstablished = false;

Loading…
Cancel
Save