paypro: refactor extension execution.
This commit is contained in:
parent
189dcb1b6f
commit
1bd9dd577f
|
@ -179,14 +179,42 @@ PayPro.prototype.x509Verify = function() {
|
||||||
// Authority Key Identifier
|
// Authority Key Identifier
|
||||||
case 35:
|
case 35:
|
||||||
extensions.authorityKeyIdentifier = ext.extnValue;
|
extensions.authorityKeyIdentifier = ext.extnValue;
|
||||||
|
// parse
|
||||||
|
extensions.authorityKeyIdentifier = rfc5280.AuthorityKeyIdentifier.decode(
|
||||||
|
extensions.authorityKeyIdentifier,
|
||||||
|
'der');
|
||||||
|
print(extensions.authorityKeyIdentifier);
|
||||||
break;
|
break;
|
||||||
// Subject Key Identifier
|
// Subject Key Identifier
|
||||||
case 14:
|
case 14:
|
||||||
extensions.subjectKeyIdentifier = ext.extnValue;
|
extensions.subjectKeyIdentifier = ext.extnValue;
|
||||||
|
// parse
|
||||||
|
// extensions.subjectKeyIdentifier = rfc5280.SubjectKeyIdentifier.decode(
|
||||||
|
// extensions.subjectKeyIdentifier,
|
||||||
|
// 'der');
|
||||||
|
// print(extensions.subjectKeyIdentifier);
|
||||||
break;
|
break;
|
||||||
// Key Usage
|
// Key Usage
|
||||||
case 15:
|
case 15:
|
||||||
extensions.keyUsage = ext.extnValue;
|
extensions.keyUsage = ext.extnValue;
|
||||||
|
// parse
|
||||||
|
data = rfc5280.KeyUsage.decode(
|
||||||
|
extensions.keyUsage,
|
||||||
|
'der').data[0];
|
||||||
|
extensions.keyUsage = {
|
||||||
|
digitalSignature: !!((data >> 0) & 1),
|
||||||
|
nonRepudiation: !!((data >> 1) & 1),
|
||||||
|
// nonRepudiation renamed to contentCommitment:
|
||||||
|
contentCommitment: !!((data >> 1) & 1),
|
||||||
|
keyEncipherment: !!((data >> 2) & 1),
|
||||||
|
dataEncipherment: !!((data >> 3) & 1),
|
||||||
|
keyAgreement: !!((data >> 4) & 1),
|
||||||
|
keyCertSign: !!((data >> 5) & 1),
|
||||||
|
cRLSign: !!((data >> 6) & 1),
|
||||||
|
encipherOnly: !!((data >> 7) & 1),
|
||||||
|
decipherOnly: !!((data >> 8) & 1)
|
||||||
|
};
|
||||||
|
print(extensions.keyUsage);
|
||||||
break;
|
break;
|
||||||
// Certificate Policies
|
// Certificate Policies
|
||||||
case 32:
|
case 32:
|
||||||
|
@ -281,44 +309,6 @@ PayPro.prototype.x509Verify = function() {
|
||||||
return ext.critical;
|
return ext.critical;
|
||||||
}).length;
|
}).length;
|
||||||
|
|
||||||
//
|
|
||||||
// Execute Extension Behavior
|
|
||||||
//
|
|
||||||
|
|
||||||
if (extensions.authorityKeyIdentifier) {
|
|
||||||
extensions.authorityKeyIdentifier = rfc5280.AuthorityKeyIdentifier.decode(
|
|
||||||
extensions.authorityKeyIdentifier,
|
|
||||||
'der');
|
|
||||||
print(extensions.authorityKeyIdentifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (extensions.subjectKeyIdentifier) {
|
|
||||||
// extensions.subjectKeyIdentifier = rfc5280.SubjectKeyIdentifier.decode(
|
|
||||||
// extensions.subjectKeyIdentifier,
|
|
||||||
// 'der');
|
|
||||||
// print(extensions.subjectKeyIdentifier);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (extensions.keyUsage) {
|
|
||||||
data = rfc5280.KeyUsage.decode(
|
|
||||||
extensions.keyUsage,
|
|
||||||
'der').data[0];
|
|
||||||
extensions.keyUsage = {
|
|
||||||
digitalSignature: !!((data >> 0) & 1),
|
|
||||||
nonRepudiation: !!((data >> 1) & 1),
|
|
||||||
// nonRepudiation renamed to contentCommitment:
|
|
||||||
contentCommitment: !!((data >> 1) & 1),
|
|
||||||
keyEncipherment: !!((data >> 2) & 1),
|
|
||||||
dataEncipherment: !!((data >> 3) & 1),
|
|
||||||
keyAgreement: !!((data >> 4) & 1),
|
|
||||||
keyCertSign: !!((data >> 5) & 1),
|
|
||||||
cRLSign: !!((data >> 6) & 1),
|
|
||||||
encipherOnly: !!((data >> 7) & 1),
|
|
||||||
decipherOnly: !!((data >> 8) & 1)
|
|
||||||
};
|
|
||||||
print(extensions.keyUsage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Verify current certificate signature
|
// Verify current certificate signature
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue