Browse Source

paypro: parse all extensions.

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

98
lib/PayPro.js

@ -183,16 +183,18 @@ PayPro.prototype.x509Verify = function() {
extensions.authorityKeyIdentifier = rfc5280.AuthorityKeyIdentifier.decode( extensions.authorityKeyIdentifier = rfc5280.AuthorityKeyIdentifier.decode(
extensions.authorityKeyIdentifier, extensions.authorityKeyIdentifier,
'der'); 'der');
print('Authority Key Identifier:');
print(extensions.authorityKeyIdentifier); print(extensions.authorityKeyIdentifier);
break; break;
// Subject Key Identifier // Subject Key Identifier
case 14: case 14:
extensions.subjectKeyIdentifier = ext.extnValue; extensions.subjectKeyIdentifier = ext.extnValue;
// parse // parse
// extensions.subjectKeyIdentifier = rfc5280.SubjectKeyIdentifier.decode( extensions.subjectKeyIdentifier = rfc5280.SubjectKeyIdentifier.decode(
// extensions.subjectKeyIdentifier, extensions.subjectKeyIdentifier,
// 'der'); 'der');
// print(extensions.subjectKeyIdentifier); print('Subject Key Identifier:');
print(extensions.subjectKeyIdentifier);
break; break;
// Key Usage // Key Usage
case 15: case 15:
@ -214,55 +216,128 @@ PayPro.prototype.x509Verify = function() {
encipherOnly: !!((data >> 7) & 1), encipherOnly: !!((data >> 7) & 1),
decipherOnly: !!((data >> 8) & 1) decipherOnly: !!((data >> 8) & 1)
}; };
print('Key Usage:');
print(extensions.keyUsage); print(extensions.keyUsage);
break; break;
// Certificate Policies // Certificate Policies
case 32: case 32:
extensions.certificatePolicies = ext.extnValue; extensions.certificatePolicies = ext.extnValue;
// parse
extensions.certificatePolicies = rfc5280.CertificatePolicies.decode(
extensions.certificatePolicies,
'der');
print('Certificate Policies:');
print(extensions.certificatePolicies);
break; break;
// Policy Mappings // Policy Mappings
case 33: case 33:
extensions.policyMappings = ext.extnValue; extensions.policyMappings = ext.extnValue;
// parse
extensions.policyMappings = rfc5280.PolicyMappings.decode(
extensions.policyMappings,
'der');
print('Policy Mappings:');
print(extensions.policyMappings);
break; break;
// Subject Alternative Name // Subject Alternative Name
case 17: case 17:
extensions.subjectAlternativeName = ext.extnValue; extensions.subjectAlternativeName = ext.extnValue;
// parse
extensions.subjectAlternativeName = rfc5280.SubjectAlternativeName.decode(
extensions.subjectAlternativeName,
'der');
print('Subject Alternative Name:');
print(extensions.subjectAlternativeName);
break; break;
// Issuer Alternative Name // Issuer Alternative Name
case 18: case 18:
extensions.issuerAlternativeName = ext.extnValue; extensions.issuerAlternativeName = ext.extnValue;
// parse
extensions.issuerAlternativeName = rfc5280.IssuerAlternativeName.decode(
extensions.issuerAlternativeName,
'der');
print('Issuer Alternative Name:');
print(extensions.issuerAlternativeName);
break; break;
// Subject Directory Attributes // Subject Directory Attributes
case 9: case 9:
extensions.subjectDirectoryAttributes = ext.extnValue; extensions.subjectDirectoryAttributes = ext.extnValue;
// parse
extensions.subjectDirectoryAttributes = rfc5280.SubjectDirectoryAttributes.decode(
extensions.subjectDirectoryAttributes,
'der');
print('Subject Directory Attributes:');
print(extensions.subjectDirectoryAttributes);
break; break;
// Basic Constraints // Basic Constraints
case 19: case 19:
extensions.basicConstraints = ext.extnValue; extensions.basicConstraints = ext.extnValue;
// parse
extensions.basicConstraints = rfc5280.BasicConstraints.decode(
extensions.basicConstraints,
'der');
print('Basic Constraints:');
print(extensions.basicConstraints);
break; break;
// Name Constraints // Name Constraints
case 30: case 30:
extensions.nameConstraints = ext.extnValue; extensions.nameConstraints = ext.extnValue;
// parse
extensions.nameConstraints = rfc5280.NameConstraints.decode(
extensions.nameConstraints,
'der');
print('Name Constraints:');
print(extensions.nameConstraints);
break; break;
// Policy Constraints // Policy Constraints
case 36: case 36:
extensions.policyConstraints = ext.extnValue; extensions.policyConstraints = ext.extnValue;
// parse
extensions.policyConstraints = rfc5280.PolicyConstraints.decode(
extensions.policyConstraints,
'der');
print('Policy Constraints:');
print(extensions.policyConstraints);
break; break;
// Extended Key Usage // Extended Key Usage
case 37: case 37:
extensions.extendedKeyUsage = ext.extnValue; extensions.extendedKeyUsage = ext.extnValue;
// parse
extensions.extendedKeyUsage = rfc5280.ExtendedKeyUsage.decode(
extensions.extendedKeyUsage,
'der');
print('Extended Key Usage');
print(extensions.extendedKeyUsage);
break; break;
// CRL Distribution Points // CRL Distribution Points
case 31: case 31:
extensions.CRLDistributionPoints = ext.extnValue; extensions.CRLDistributionPoints = ext.extnValue;
// parse
extensions.CRLDistributionPoints = rfc5280.CRLDistributionPoints.decode(
extensions.CRLDistributionPoints,
'der');
print('CRL Distribution Points:');
print(extensions.CRLDistributionPoints);
break; break;
// Inhibit anyPolicy // Inhibit anyPolicy
case 54: case 54:
extensions.inhibitAnyPolicy = ext.extnValue; extensions.inhibitAnyPolicy = ext.extnValue;
// parse
extensions.inhibitAnyPolicy = rfc5280.InhibitAnyPolicy.decode(
extensions.inhibitAnyPolicy,
'der');
print('Inhibit Any Policy:');
print(extensions.inhibitAnyPolicy);
break; break;
// Freshest CRL // Freshest CRL
case 46: case 46:
extensions.freshestCRL = ext.extnValue; extensions.freshestCRL = ext.extnValue;
// parse
extensions.freshestCRL = rfc5280.FreshestCRL.decode(
extensions.freshestCRL,
'der');
print('Freshest CRL:');
print(extensions.freshestCRL);
break; break;
// Unknown Extension (not documented anywhere, probably non-standard) // Unknown Extension (not documented anywhere, probably non-standard)
default: default:
@ -287,11 +362,23 @@ PayPro.prototype.x509Verify = function() {
// id-pe: // id-pe:
case 1: case 1:
extensions.authorityInformationAccess = ext.extnValue; extensions.authorityInformationAccess = ext.extnValue;
// parse
extensions.authorityInformationAccess = rfc5280.AuthorityInformationAccess.decode(
extensions.authorityInformationAccess,
'der');
print('Authority Information Access:');
print(extensions.freshestCRL);
break; break;
// Subject Information Access // Subject Information Access
// id-pe: // id-pe:
case 11: case 11:
extensions.subjectInformationAccess = ext.extnValue; extensions.subjectInformationAccess = ext.extnValue;
// parse
extensions.subjectInformationAccess = rfc5280.SubjectInformationAccess.decode(
extensions.subjectInformationAccess,
'der');
print('Subject Information Access:');
print(extensions.subjectInformationAccess);
break; break;
// Unknown Extension (not documented anywhere, probably non-standard) // Unknown Extension (not documented anywhere, probably non-standard)
default: default:
@ -802,7 +889,8 @@ var Attribute = rfc5280.AttributeTypeAndValue = AttributeTypeAndValue;
var BasicConstraints = var BasicConstraints =
rfc5280.BasicConstraints = asn1.define('BasicConstraints', function() { rfc5280.BasicConstraints = asn1.define('BasicConstraints', function() {
this.seq().obj( this.seq().obj(
this.key('cA').default(false).bool(), // this.key('cA').default(false).bool(),
this.key('cA').bool(),
this.key('pathLenConstraint').optional().int() this.key('pathLenConstraint').optional().int()
); );
}); });

Loading…
Cancel
Save