|
|
@ -3600,8 +3600,12 @@ try { |
|
|
|
|
|
|
|
|
|
|
|
function Credentials (method) { |
|
|
|
if (!(this instanceof Credentials)) { |
|
|
|
return new Credentials(method); |
|
|
|
} |
|
|
|
|
|
|
|
if (!crypto) { |
|
|
|
throw new Error('node.js not compiled with openssl crypto support.'); |
|
|
|
throw new Error('node.js not compiled with openssl crypto support.'); |
|
|
|
} |
|
|
|
|
|
|
|
this.context = new SecureContext(); |
|
|
@ -3615,28 +3619,34 @@ function Credentials (method) { |
|
|
|
this.shouldVerify = false; |
|
|
|
} |
|
|
|
|
|
|
|
exports.Credentials = Credentials; |
|
|
|
|
|
|
|
|
|
|
|
exports.createCredentials = function (options) { |
|
|
|
if (!options) options = {}; |
|
|
|
var c = new Credentials(options.method); |
|
|
|
|
|
|
|
exports.createCredentials = function (cred) { |
|
|
|
if (!cred) cred={}; |
|
|
|
var c = new Credentials(cred.method); |
|
|
|
if (cred.key) c.context.setKey(cred.key); |
|
|
|
if (cred.cert) c.context.setCert(cred.cert); |
|
|
|
if (cred.ca) { |
|
|
|
if (options.key) c.context.setKey(options.key); |
|
|
|
|
|
|
|
if (options.cert) c.context.setCert(options.cert); |
|
|
|
|
|
|
|
if (options.ca) { |
|
|
|
c.shouldVerify = true; |
|
|
|
if ( (typeof(cred.ca) == 'object') && cred.ca.length ) { |
|
|
|
for(var i = 0, len = cred.ca.length; i < len; i++) |
|
|
|
c.context.addCACert(cred.ca[i]); |
|
|
|
if ( (typeof(options.ca) == 'object') && options.ca.length ) { |
|
|
|
for (var i = 0, len = options.ca.length; i < len; i++) { |
|
|
|
c.context.addCACert(options.ca[i]); |
|
|
|
} |
|
|
|
} else { |
|
|
|
c.context.addCACert(cred.ca); |
|
|
|
c.context.addCACert(options.ca); |
|
|
|
} |
|
|
|
} else { |
|
|
|
for (var i = 0, len = RootCaCerts.length; i < len; i++) { |
|
|
|
c.context.addCACert(RootCaCerts[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return c; |
|
|
|
}; |
|
|
|
exports.Credentials = Credentials; |
|
|
|
|
|
|
|
|
|
|
|
exports.Hash = Hash; |
|
|
|