paypro: better extension parsing with more debugging.
This commit is contained in:
parent
95a75a6ee4
commit
b52eb6f922
@ -133,40 +133,62 @@ PayPro.prototype.x509Verify = function() {
|
|||||||
// http://tools.ietf.org/html/rfc5280#section-4.2
|
// http://tools.ietf.org/html/rfc5280#section-4.2
|
||||||
//
|
//
|
||||||
|
|
||||||
// Basic Constraints
|
var ext;
|
||||||
var basicConstraints = nc.tbsCertificate.extensions.filter(function(ext) {
|
var eid;
|
||||||
return ext.extnID[3] === 19;
|
var extensions = {
|
||||||
})[0];
|
basicConstraints: null,
|
||||||
|
keyUsage: null,
|
||||||
|
subjectKeyIdentifier: null,
|
||||||
|
authKeyIdentifier: null,
|
||||||
|
CRLDistributionPoints: null,
|
||||||
|
certificatePolicies: null,
|
||||||
|
standardUnknown: [],
|
||||||
|
unknown: [],
|
||||||
|
};
|
||||||
|
|
||||||
// Key Usage
|
for (var i = 0; i < nc.tbsCertificate.extensions.length; i++) {
|
||||||
var keyUsage = nc.tbsCertificate.extensions.filter(function(ext) {
|
ext = nc.tbsCertificate.extensions[i];
|
||||||
return ext.extnID[3] === 15;
|
eid = ext.extnID;
|
||||||
})[0];
|
if (eid.length === 4 && eid[0] === 2 && eid[1] === 5 && eid[2] === 29) {
|
||||||
|
switch (eid[3]) {
|
||||||
|
// Basic Constraints
|
||||||
|
case 19:
|
||||||
|
extensions.basicConstraints = ext;
|
||||||
|
break;
|
||||||
|
// Key Usage
|
||||||
|
case 15:
|
||||||
|
extensions.keyUsage = ext;
|
||||||
|
break;
|
||||||
|
// Subject Key Identifier
|
||||||
|
case 14:
|
||||||
|
extensions.subjectKeyIdentifier = ext;
|
||||||
|
break;
|
||||||
|
// Authority Key Identifier
|
||||||
|
case 35:
|
||||||
|
extensions.authKeyIdentifier = ext;
|
||||||
|
break;
|
||||||
|
// CRL Distribution Points
|
||||||
|
case 31:
|
||||||
|
extensions.CRLDistributionPoints = ext;
|
||||||
|
break;
|
||||||
|
// Certificate Policies
|
||||||
|
case 32:
|
||||||
|
extensions.certificatePolicies = ext;
|
||||||
|
break;
|
||||||
|
// Unknown Extension (not documented anywhere, probably non-standard)
|
||||||
|
default:
|
||||||
|
extensions.standardUnknown.push(ext);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
extensions.unknown.push(ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subject Key Identifier
|
print(c);
|
||||||
var authKeyIdentifier = nc.tbsCertificate.extensions.filter(function(ext) {
|
print(nc);
|
||||||
return ext.extnID[3] === 14;
|
print('issuerVerified: %s', issuerVerified);
|
||||||
})[0];
|
print(extensions);
|
||||||
|
|
||||||
// Authority Key Identifier
|
|
||||||
var authKeyIdentifier = nc.tbsCertificate.extensions.filter(function(ext) {
|
|
||||||
return ext.extnID[3] === 35;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
// Unknown Extension (not documented anywhere, probably non-standard)
|
|
||||||
var unknown = nc.tbsCertificate.extensions.filter(function(ext) {
|
|
||||||
return ext.extnID[3] === 1;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
// CRL Distribution Points
|
|
||||||
var CRLDistributionPoints = nc.tbsCertificate.extensions.filter(function(ext) {
|
|
||||||
return ext.extnID[3] === 31;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
// Certificate Policies
|
|
||||||
var certPolicies = nc.tbsCertificate.extensions.filter(function(ext) {
|
|
||||||
return ext.extnID[3] === 32;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a To-Be-Signed Certificate to verify using asn1.js:
|
// Create a To-Be-Signed Certificate to verify using asn1.js:
|
||||||
@ -184,4 +206,16 @@ PayPro.prototype.x509Verify = function() {
|
|||||||
return verified && chainVerified;
|
return verified && chainVerified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
|
function inspect(obj) {
|
||||||
|
return typeof obj !== 'string'
|
||||||
|
? util.inspect(obj, false, 20, true)
|
||||||
|
: obj;
|
||||||
|
}
|
||||||
|
function print(obj) {
|
||||||
|
return typeof obj === 'object'
|
||||||
|
? process.stdout.write(inspect(obj) + '\n')
|
||||||
|
: console.log.apply(console, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = PayPro;
|
module.exports = PayPro;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user