|
|
@ -18,15 +18,19 @@ PayPro.prototype.x509Sign = function(key) { |
|
|
|
var type = pki_type.split('+')[1].toUpperCase(); |
|
|
|
var buf = this.serializeForSig(); |
|
|
|
|
|
|
|
var trusted = [].concat(pki_data).every(function(cert) { |
|
|
|
var trusted = pki_data.map(function(cert) { |
|
|
|
var der = cert.toString('hex'); |
|
|
|
var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(der, 'CERTIFICATE'); |
|
|
|
return RootCerts.isTrusted(pem); |
|
|
|
return RootCerts.getTrusted(pem); |
|
|
|
}); |
|
|
|
|
|
|
|
if (!trusted) { |
|
|
|
// XXX Figure out what to do here
|
|
|
|
// XXX Figure out what to do here
|
|
|
|
if (!trusted.length) { |
|
|
|
// throw new Error('Unstrusted certificate.');
|
|
|
|
} else { |
|
|
|
trusted.forEach(function(name) { |
|
|
|
// console.log('Certificate: %s', name);
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var rsa = new KJUR.RSAKey(); |
|
|
@ -38,9 +42,6 @@ PayPro.prototype.x509Sign = function(key) { |
|
|
|
prov: 'cryptojs/jsrsa' |
|
|
|
}); |
|
|
|
|
|
|
|
// XXX Could use this?
|
|
|
|
//jsrsaSig.initSign(key);
|
|
|
|
|
|
|
|
jsrsaSig.init(key); |
|
|
|
|
|
|
|
jsrsaSig.updateHex(buf.toString('hex')); |
|
|
@ -63,13 +64,16 @@ PayPro.prototype.x509Verify = function(key) { |
|
|
|
prov: 'cryptojs/jsrsa' |
|
|
|
}); |
|
|
|
|
|
|
|
return [].concat(pki_data).every(function(cert) { |
|
|
|
return pki_data.every(function(cert) { |
|
|
|
var der = cert.toString('hex'); |
|
|
|
var pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(der, 'CERTIFICATE'); |
|
|
|
|
|
|
|
if (!RootCerts.isTrusted(pem)) { |
|
|
|
// XXX Figure out what to do here
|
|
|
|
// XXX Figure out what to do here
|
|
|
|
var name = RootCerts.getTrusted(pem); |
|
|
|
if (!name) { |
|
|
|
// throw new Error('Unstrusted certificate.');
|
|
|
|
} else { |
|
|
|
// console.log('Certificate: %s', name);
|
|
|
|
} |
|
|
|
|
|
|
|
jsrsaSig.initVerifyByCertificatePEM(pem); |
|
|
|