diff --git a/lib/PayPro.js b/lib/PayPro.js index 1e2fed5..7b02aa0 100644 --- a/lib/PayPro.js +++ b/lib/PayPro.js @@ -213,6 +213,20 @@ PayPro.prototype.x509Verify = function() { print(extensions.authorityKeyIdentifier); } + // if (extensions.subjectKeyIdentifier) { + // extensions.subjectKeyIdentifier = rfc5280.SubjectKeyIdentifier.decode( + // extensions.subjectKeyIdentifier, + // 'der'); + // print(extensions.subjectKeyIdentifier); + // } + + if (extensions.keyUsage) { + extensions.keyUsage = rfc5280.KeyUsage.decode( + extensions.keyUsage, + 'der'); + print(extensions.keyUsage); + } + // // Verify current certificate signature // @@ -246,6 +260,7 @@ PayPro.prototype.x509Verify = function() { */ var rfc5280 = {}; + rfc5280.AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function() { this.seq().obj( this.key('keyIdentifier').optional().octstr(), @@ -254,6 +269,32 @@ rfc5280.AuthorityKeyIdentifier = asn1.define('AuthorityKeyIdentifier', function( ); }); +// rfc5280.SubjectKeyIdentifier = asn1.define('SubjectKeyIdentifier', function() { +// this.seq().obj( +// this.key('keyIdentifier').optional().octstr(), +// this.key('authorityCertIssuer').optional().octstr(), +// this.key('authorityCertSerialNumber').optional().octstr() +// ); +// }); + +rfc5280.KeyUsage = asn1.define('KeyUsage', function() { + this.bitstr(); +}); + +rfc5280.KeyUsage = asn1.define('KeyUsage', function() { + this.seq().obj( + this.key('digitalSignature').bitstr(), + this.key('nonRepudiation').bitstr(), + this.key('keyEncipherment').bitstr(), + this.key('dataEncipherment').bitstr(), + this.key('keyAgreement').bitstr(), + this.key('keyCertSign').bitstr(), + this.key('cRLSign').bitstr(), + this.key('encipherOnly').bitstr(), + this.key('decipherOnly').bitstr() + ); +}); + /** * Debug */