Browse Source

paypro: refactor extension parsing.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
dde64fbb87
  1. 18
      lib/PayPro.js

18
lib/PayPro.js

@ -146,9 +146,7 @@ PayPro.prototype.x509Verify = function() {
// http://tools.ietf.org/html/rfc5280#section-4.2 // http://tools.ietf.org/html/rfc5280#section-4.2
// //
var extensions = rfc5280.decodeExtensions(c, { partial: false }); var extensions = rfc5280.decodeExtensions(c, { partial: false });
var extensionsVerified = !extensions.unknown.filter(function(ext) { var extensionsVerified = extensions.verified;
return ext.critical;
}).length;
// Object.keys(extensions).forEach(function(key) { // Object.keys(extensions).forEach(function(key) {
// if (extensions[key].execute) { // if (extensions[key].execute) {
@ -1078,16 +1076,18 @@ rfc5280.decodeExtensions = function(cert, options) {
// Parse Extension // Parse Extension
decoded = ext.schema.decode(edata.extnValue, 'der', options); decoded = ext.schema.decode(edata.extnValue, 'der', options);
// partial: true throws everything onto: { result: ..., errors: ... }
if (options.partial && decoded.result) { if (options.partial && decoded.result) {
errors = decoded.errors; errors = decoded.errors;
decoded = decoded.result; if (Array.isArray(decoded.result)) {
if (Array.isArray(decoded)) { decoded = decoded.result.map(function(decoded) {
decoded = decoded.map(function(decoded) {
decoded.errors.forEach(function(error) { decoded.errors.forEach(function(error) {
errors.push(error); errors.push(error);
}); });
return decoded.result; return decoded.result;
}); });
} else {
decoded = decoded.result;
} }
} }
@ -1101,7 +1101,6 @@ rfc5280.decodeExtensions = function(cert, options) {
// Comment for debugging: // Comment for debugging:
// data.edata = edata; // data.edata = edata;
// data.ext = ext; // data.ext = ext;
data.errors = errors;
if (ext.parse) { if (ext.parse) {
data.decoded = decoded; data.decoded = decoded;
} }
@ -1129,13 +1128,16 @@ rfc5280.decodeExtensions = function(cert, options) {
} else { } else {
// Add unknown extension: // Add unknown extension:
output.unknown.push(edata); output.unknown.push(edata);
output['unkown_' + (output.unknown.length - 1)] = edata;
// XXX Debug // XXX Debug
print('Unknown extension: %s', eid); print('Unknown extension: %s', eid);
} }
} }
extensions.verified = !extensions.unknown.filter(function(ext) {
return ext.critical;
}).length;
return output; return output;
}; };

Loading…
Cancel
Save