diff --git a/lib/PayPro.js b/lib/PayPro.js index aff6a6b..fe557f6 100644 --- a/lib/PayPro.js +++ b/lib/PayPro.js @@ -163,6 +163,14 @@ PayPro.prototype.x509Verify = function() { eid = ext.extnID; if (eid.length === 4 && eid[0] === 2 && eid[1] === 5 && eid[2] === 29) { switch (eid[3]) { + // Authority Key Identifier + case 35: + extensions.authorityKeyIdentifier = ext.extnValue; + break; + // Subject Key Identifier + case 14: + extensions.subjectKeyIdentifier = ext.extnValue; + break; // Basic Constraints case 19: extensions.basicConstraints = ext.extnValue; @@ -171,14 +179,6 @@ PayPro.prototype.x509Verify = function() { case 15: extensions.keyUsage = ext.extnValue; break; - // Subject Key Identifier - case 14: - extensions.subjectKeyIdentifier = ext.extnValue; - break; - // Authority Key Identifier - case 35: - extensions.authorityKeyIdentifier = ext.extnValue; - break; // CRL Distribution Points case 31: extensions.CRLDistributionPoints = ext.extnValue; @@ -274,20 +274,50 @@ PayPro.prototype.x509Verify = function() { var rfc5280 = {}; +/** + * # AuthorityKeyIdentifier + */ + var AuthorityKeyIdentifier = rfc5280.AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function() { this.seq().obj( - this.key('keyIdentifier').optional().octstr(), - this.key('authorityCertIssuer').optional().octstr(), - this.key('authorityCertSerialNumber').optional().octstr() + this.key('keyIdentifier').optional().use(KeyIdentifier), + this.key('authorityCertIssuer').optional().use(GeneralNames), + this.key('authorityCertSerialNumber').optional().use(CertificateSerialNumber) ); }); +/** + * ## KeyIdentifier + */ + +var KeyIdentifier = +rfc5280.KeyIdentifier = asn1.define('KeyIdentifier', function() { + this.octstr(); +}); + +/** + * ## CertificateSerialNumber + */ + +var CertificateSerialNumber = +rfc5280.CertificateSerialNumber = asn1.define('CertificateSerialNumber', function() { + this.int(); +}); + +/** + * ## GeneralNames + */ + var GeneralNames = rfc5280.GeneralNames = asn1.define('GeneralNames', function() { this.seqof(GeneralName); }); +/** + * ### GeneralName + */ + var GeneralName = rfc5280.GeneralName = asn1.define('GeneralName', function() { this.choice({ @@ -303,6 +333,10 @@ rfc5280.GeneralName = asn1.define('GeneralName', function() { }); }); +/** + * #### OtherName + */ + var OtherName = rfc5280.OtherName = asn1.define('OtherName', function() { this.seq().obj( @@ -311,6 +345,10 @@ rfc5280.OtherName = asn1.define('OtherName', function() { ); }); +/** + * #### ORAddress + */ + var ORAddress = rfc5280.ORAddress = asn1.define('ORAddress', function() { this.seq().obj( @@ -320,6 +358,10 @@ rfc5280.ORAddress = asn1.define('ORAddress', function() { ); }); +/** + * ##### BuiltInStandardAttributes + */ + var BuiltInStandardAttributes = rfc5280.BuiltInStandardAttributes = asn1.define('BuiltInStandardAttributes', function() { this.seq().obj( @@ -336,7 +378,7 @@ rfc5280.BuiltInStandardAttributes = asn1.define('BuiltInStandardAttributes', fun }); /** - * For BuiltInStandardAttributes + * ###### CountryName */ var CountryName = @@ -347,6 +389,10 @@ rfc5280.CountryName = asn1.define('CountryName', function() { }); }); +/** + * ###### AdministrationDomainName + */ + var AdministrationDomainName = rfc5280.AdministrationDomainName = asn1.define('AdministrationDomainName', function() { this.choice({ @@ -355,21 +401,37 @@ rfc5280.AdministrationDomainName = asn1.define('AdministrationDomainName', funct }); }); +/** + * ###### NetworkAddress + */ + var NetworkAddress = rfc5280.NetworkAddress = asn1.define('NetworkAddress', function() { this.use(X121Address); }); +/** + * ###### X121Address + */ + var X121Address = rfc5280.X121Address = asn1.define('X121Address', function() { this.numstr(); }); +/** + * ###### TerminalIdentifier + */ + var TerminalIdentifier = rfc5280.TerminalIdentifier = asn1.define('TerminalIdentifier', function() { this.printstr(); }); +/** + * ###### PrivateDomainName + */ + var PrivateDomainName = rfc5280.PrivateDomainName = asn1.define('PrivateDomainName', function() { this.choice({ @@ -378,16 +440,28 @@ rfc5280.PrivateDomainName = asn1.define('PrivateDomainName', function() { }); }); +/** + * ###### OrganizationName + */ + var OrganizationName = rfc5280.OrganizationName = asn1.define('OrganizationName', function() { this.printstr(); }); +/** + * ###### NumericUserIdentifier + */ + var NumericUserIdentifier = rfc5280.NumericUserIdentifier = asn1.define('NumericUserIdentifier', function() { this.numstr(); }); +/** + * ###### PersonalName + */ + var PersonalName = rfc5280.PersonalName = asn1.define('PersonalName', function() { this.set().obj( @@ -398,18 +472,26 @@ rfc5280.PersonalName = asn1.define('PersonalName', function() { ); }); +/** + * ###### OrganizationalUnitNames + */ + var OrganizationalUnitNames = rfc5280.OrganizationalUnitNames = asn1.define('OrganizationalUnitNames', function() { this.seqof(OrganizationalUnitName); }); +/** + * ####### OrganizationalUnitName + */ + var OrganizationalUnitName = rfc5280.OrganizationalUnitName = asn1.define('OrganizationalUnitName', function() { this.printstr(); }); /** - * BuiltInDomainDefinedAttributes + * ##### BuiltInDomainDefinedAttributes */ var BuiltInDomainDefinedAttributes = @@ -418,7 +500,7 @@ rfc5280.BuiltInDomainDefinedAttributes = asn1.define('BuiltInDomainDefinedAttrib }); /** - * For BuiltInDomainDefinedAttribute + * ###### BuiltInDomainDefinedAttribute */ var BuiltInDomainDefinedAttribute = @@ -430,7 +512,7 @@ rfc5280.BuiltInDomainDefinedAttribute = asn1.define('BuiltInDomainDefinedAttribu }); /** - * ExtensionAttributes + * # ExtensionAttributes */ var ExtensionAttributes = @@ -439,7 +521,7 @@ rfc5280.ExtensionAttributes = asn1.define('ExtensionAttributes', function() { }); /** - * For ExtensionAttributes + * ## ExtensionAttribute */ var ExtensionAttribute = @@ -451,7 +533,7 @@ rfc5280.ExtensionAttribute = asn1.define('ExtensionAttribute', function() { }); /** - * EDIPartyName + * #### EDIPartyName */ var EDIPartyName = @@ -469,6 +551,10 @@ rfc5280.EDIPartyName = asn1.define('EDIPartyName', function() { // https://www.google.com/search?q=TeletexString // http://msdn.microsoft.com/en-us/library/windows/desktop/bb540814(v=vs.85).aspx +/** + * ##### DirectoryString + */ + var DirectoryString = rfc5280.DirectoryString = asn1.define('DirectoryString', function() { this.choice({ @@ -480,6 +566,10 @@ rfc5280.DirectoryString = asn1.define('DirectoryString', function() { }); }); +/** + * # KeyUsage + */ + var KeyUsage = rfc5280.KeyUsage = asn1.define('KeyUsage', function() { this.bitstr();