mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
style
This commit is contained in:
parent
e15e214747
commit
09157369b3
@ -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 (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) {
|
||||
|
||||
exports.createCredentials = function (options) {
|
||||
if (!options) options = {};
|
||||
var c = new Credentials(options.method);
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user