|
|
@ -4,14 +4,7 @@ var Key = require('./Key'); |
|
|
|
var KJUR = require('./x509'); |
|
|
|
var assert = require('assert'); |
|
|
|
var PayPro = require('../PayPro'); |
|
|
|
var Trusted = require('../RootCerts'); |
|
|
|
|
|
|
|
// Use hash table for efficiency:
|
|
|
|
Trusted = Trusted.reduce(function(trusted, cert) { |
|
|
|
cert = cert.replace(/\s+/g, ''); |
|
|
|
trusted[cert] = true; |
|
|
|
return trusted; |
|
|
|
}, {}); |
|
|
|
var RootCerts = require('../RootCerts'); |
|
|
|
|
|
|
|
PayPro.sign = function(key) { |
|
|
|
if (this.messageType !== 'PaymentRequest') |
|
|
@ -32,7 +25,7 @@ PayPro.sign = function(key) { |
|
|
|
var trusted = [].concat(pki_data).every(function(cert) { |
|
|
|
var der = cert.toString('hex'); |
|
|
|
var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(der, 'CERTIFICATE'); |
|
|
|
return !!Trusted[pem.replace(/\s+/g, '')]; |
|
|
|
return !!RootCerts[pem.replace(/\s+/g, '')]; |
|
|
|
}); |
|
|
|
|
|
|
|
if (!trusted) { |
|
|
@ -82,7 +75,7 @@ PayPro.verify = function() { |
|
|
|
var der = cert.toString('hex'); |
|
|
|
var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(der, 'CERTIFICATE'); |
|
|
|
|
|
|
|
if (!Trusted[pem.replace(/\s+/g, '')]) { |
|
|
|
if (!RootCerts[pem.replace(/\s+/g, '')]) { |
|
|
|
// throw new Error('Unstrusted certificate.');
|
|
|
|
} |
|
|
|
|
|
|
|