Merge pull request #446 from chjj/paypro
PayPro: Fix payment protocol with regards to pki_data DER certs
This commit is contained in:
commit
1936bfd374
|
@ -11,6 +11,8 @@ PayPro.prototype.x509Sign = function(key) {
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
var pki_data = this.get('pki_data'); // contains one or more x509 certs
|
var pki_data = this.get('pki_data'); // contains one or more x509 certs
|
||||||
|
pki_data = PayPro.X509Certificates.decode(pki_data);
|
||||||
|
pki_data = pki_data.certificate;
|
||||||
var details = this.get('serialized_payment_details');
|
var details = this.get('serialized_payment_details');
|
||||||
var type = pki_type.split('+')[1].toUpperCase();
|
var type = pki_type.split('+')[1].toUpperCase();
|
||||||
|
|
||||||
|
@ -38,6 +40,8 @@ PayPro.prototype.x509Verify = function() {
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
var sig = this.get('signature');
|
var sig = this.get('signature');
|
||||||
var pki_data = this.get('pki_data');
|
var pki_data = this.get('pki_data');
|
||||||
|
pki_data = PayPro.X509Certificates.decode(pki_data);
|
||||||
|
pki_data = pki_data.certificate;
|
||||||
var details = this.get('serialized_payment_details');
|
var details = this.get('serialized_payment_details');
|
||||||
var buf = this.serializeForSig();
|
var buf = this.serializeForSig();
|
||||||
var type = pki_type.split('+')[1].toUpperCase();
|
var type = pki_type.split('+')[1].toUpperCase();
|
||||||
|
|
|
@ -13,6 +13,8 @@ var RootCerts = require('../common/RootCerts');
|
||||||
PayPro.prototype.x509Sign = function(key) {
|
PayPro.prototype.x509Sign = function(key) {
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
var pki_data = this.get('pki_data'); // contains one or more x509 certs
|
var pki_data = this.get('pki_data'); // contains one or more x509 certs
|
||||||
|
pki_data = PayPro.X509Certificates.decode(pki_data);
|
||||||
|
pki_data = pki_data.certificate;
|
||||||
var type = pki_type.split('+')[1].toUpperCase();
|
var type = pki_type.split('+')[1].toUpperCase();
|
||||||
var buf = this.serializeForSig();
|
var buf = this.serializeForSig();
|
||||||
|
|
||||||
|
@ -51,6 +53,8 @@ PayPro.prototype.x509Verify = function(key) {
|
||||||
var sig = this.get('signature');
|
var sig = this.get('signature');
|
||||||
var pki_type = this.get('pki_type');
|
var pki_type = this.get('pki_type');
|
||||||
var pki_data = this.get('pki_data');
|
var pki_data = this.get('pki_data');
|
||||||
|
pki_data = PayPro.X509Certificates.decode(pki_data);
|
||||||
|
pki_data = pki_data.certificate;
|
||||||
var buf = this.serializeForSig();
|
var buf = this.serializeForSig();
|
||||||
var type = pki_type.split('+')[1].toUpperCase();
|
var type = pki_type.split('+')[1].toUpperCase();
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,13 @@ describe('PayPro', function() {
|
||||||
paypro.makePaymentRequest();
|
paypro.makePaymentRequest();
|
||||||
paypro.set('serialized_payment_details', pdbuf);
|
paypro.set('serialized_payment_details', pdbuf);
|
||||||
paypro.set('pki_type', 'x509+sha256');
|
paypro.set('pki_type', 'x509+sha256');
|
||||||
paypro.set('pki_data', x509.der);
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
paypro.sign(x509.priv);
|
paypro.sign(x509.priv);
|
||||||
x509.sig1 = paypro.get('signature');
|
x509.sig1 = paypro.get('signature');
|
||||||
x509.sig1.length.should.be.greaterThan(0);
|
x509.sig1.length.should.be.greaterThan(0);
|
||||||
|
@ -388,7 +394,13 @@ describe('PayPro', function() {
|
||||||
paypro.set('serialized_payment_details', pdbuf);
|
paypro.set('serialized_payment_details', pdbuf);
|
||||||
paypro.set('pki_type', 'x509+sha256');
|
paypro.set('pki_type', 'x509+sha256');
|
||||||
paypro.set('signature', x509.sig1); // sig buffer
|
paypro.set('signature', x509.sig1); // sig buffer
|
||||||
paypro.set('pki_data', x509.der); // contains one or more x509 certs
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
var verify = paypro.verify();
|
var verify = paypro.verify();
|
||||||
verify.should.equal(true);
|
verify.should.equal(true);
|
||||||
});
|
});
|
||||||
|
@ -446,7 +458,12 @@ describe('PayPro', function() {
|
||||||
|
|
||||||
paypro.set('serialized_payment_details', pdbuf);
|
paypro.set('serialized_payment_details', pdbuf);
|
||||||
paypro.set('pki_type', 'x509+sha256');
|
paypro.set('pki_type', 'x509+sha256');
|
||||||
paypro.set('pki_data', x509.der);
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
var sig = paypro.x509Sign(x509.priv);
|
var sig = paypro.x509Sign(x509.priv);
|
||||||
paypro.set('signature', sig);
|
paypro.set('signature', sig);
|
||||||
|
@ -470,7 +487,12 @@ describe('PayPro', function() {
|
||||||
paypro.set('pki_type', 'x509+sha256');
|
paypro.set('pki_type', 'x509+sha256');
|
||||||
|
|
||||||
paypro.set('signature', x509.sig2); // sig buffer
|
paypro.set('signature', x509.sig2); // sig buffer
|
||||||
paypro.set('pki_data', x509.der); // contains one or more x509 certs
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
var verify = paypro.x509Verify();
|
var verify = paypro.x509Verify();
|
||||||
verify.should.equal(true);
|
verify.should.equal(true);
|
||||||
|
@ -489,7 +511,12 @@ describe('PayPro', function() {
|
||||||
|
|
||||||
paypro.set('serialized_payment_details', pdbuf);
|
paypro.set('serialized_payment_details', pdbuf);
|
||||||
paypro.set('pki_type', 'x509+sha1');
|
paypro.set('pki_type', 'x509+sha1');
|
||||||
paypro.set('pki_data', x509.der);
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
var sig = paypro.x509Sign(x509.priv);
|
var sig = paypro.x509Sign(x509.priv);
|
||||||
paypro.set('signature', sig);
|
paypro.set('signature', sig);
|
||||||
|
@ -513,7 +540,12 @@ describe('PayPro', function() {
|
||||||
paypro.set('pki_type', 'x509+sha1');
|
paypro.set('pki_type', 'x509+sha1');
|
||||||
|
|
||||||
paypro.set('signature', x509.sig3); // sig buffer
|
paypro.set('signature', x509.sig3); // sig buffer
|
||||||
paypro.set('pki_data', x509.der); // contains one or more x509 certs
|
|
||||||
|
var cr = new PayPro();
|
||||||
|
cr = cr.makeX509Certificates();
|
||||||
|
cr.set('certificate', [x509.der]);
|
||||||
|
|
||||||
|
paypro.set('pki_data', cr.serialize()); // contains one or more x509 certs
|
||||||
|
|
||||||
var verify = paypro.x509Verify();
|
var verify = paypro.x509Verify();
|
||||||
verify.should.equal(true);
|
verify.should.equal(true);
|
||||||
|
|
Loading…
Reference in New Issue