|
|
@ -36,7 +36,7 @@ try { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function Credentials(secureProtocol) { |
|
|
|
function Credentials(secureProtocol, context) { |
|
|
|
if (!(this instanceof Credentials)) { |
|
|
|
return new Credentials(secureProtocol); |
|
|
|
} |
|
|
@ -45,22 +45,28 @@ function Credentials(secureProtocol) { |
|
|
|
throw new Error('node.js not compiled with openssl crypto support.'); |
|
|
|
} |
|
|
|
|
|
|
|
this.context = new SecureContext(); |
|
|
|
|
|
|
|
if (secureProtocol) { |
|
|
|
this.context.init(secureProtocol); |
|
|
|
if (context) { |
|
|
|
this.context = context; |
|
|
|
this.reuseContext = true; |
|
|
|
} else { |
|
|
|
this.context.init(); |
|
|
|
} |
|
|
|
this.context = new SecureContext(); |
|
|
|
|
|
|
|
if (secureProtocol) { |
|
|
|
this.context.init(secureProtocol); |
|
|
|
} else { |
|
|
|
this.context.init(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
exports.Credentials = Credentials; |
|
|
|
|
|
|
|
|
|
|
|
exports.createCredentials = function(options) { |
|
|
|
exports.createCredentials = function(options, context) { |
|
|
|
if (!options) options = {}; |
|
|
|
var c = new Credentials(options.secureProtocol); |
|
|
|
var c = new Credentials(options.secureProtocol, context); |
|
|
|
|
|
|
|
if (context) return c; |
|
|
|
|
|
|
|
if (options.key) c.context.setKey(options.key); |
|
|
|
|
|
|
|