|
|
@ -93,6 +93,42 @@ PayPro.getTBSCertificate = function(data) { |
|
|
|
return data.slice(start, end); |
|
|
|
}; |
|
|
|
|
|
|
|
// Check Validity of Certificates
|
|
|
|
PayPro.validateCertTime = function(c, nc) { |
|
|
|
var validityVerified = true; |
|
|
|
var now = Date.now(); |
|
|
|
var cBefore = c.tbsCertificate.validity.notBefore.value; |
|
|
|
var cAfter = c.tbsCertificate.validity.notAfter.value; |
|
|
|
var nBefore = nc.tbsCertificate.validity.notBefore.value; |
|
|
|
var nAfter = nc.tbsCertificate.validity.notAfter.value; |
|
|
|
if (cBefore > now || cAfter < now || nBefore > now || nAfter < now) { |
|
|
|
validityVerified = false; |
|
|
|
} |
|
|
|
return validityVerified; |
|
|
|
}; |
|
|
|
|
|
|
|
// Check the Issuer matches the Subject of the next certificate:
|
|
|
|
PayPro.validateCertIssuer = function(c, nc) { |
|
|
|
var issuer = c.tbsCertificate.issuer; |
|
|
|
var subject = nc.tbsCertificate.subject; |
|
|
|
var issuerVerified = issuer.type === subject.type && issuer.value.every(function(issuerArray, i) { |
|
|
|
var subjectArray = subject.value[i]; |
|
|
|
return issuerArray.every(function(issuerObject, i) { |
|
|
|
var subjectObject = subjectArray[i]; |
|
|
|
|
|
|
|
var issuerObjectType = issuerObject.type.join('.'); |
|
|
|
var subjectObjectType = subjectObject.type.join('.'); |
|
|
|
|
|
|
|
var issuerObjectValue = issuerObject.value.toString('hex'); |
|
|
|
var subjectObjectValue = subjectObject.value.toString('hex'); |
|
|
|
|
|
|
|
return issuerObjectType === subjectObjectType |
|
|
|
&& issuerObjectValue === subjectObjectValue; |
|
|
|
}); |
|
|
|
}); |
|
|
|
return issuerVerified; |
|
|
|
}; |
|
|
|
|
|
|
|
PayPro.RootCerts = RootCerts; |
|
|
|
|
|
|
|
PayPro.proto = {}; |
|
|
|