|
|
@ -93,65 +93,13 @@ PayPro.prototype.x509Verify = function() { |
|
|
|
var data = new Buffer(nder, 'hex'); |
|
|
|
var nc = rfc3280.Certificate.decode(data, 'der'); |
|
|
|
var npubKey = nc.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey.data; |
|
|
|
npubKey = npubKey.toString('hex'); |
|
|
|
//npubKey = self._DERtoPEM(npubKey, 'RSA PUBLIC KEY');
|
|
|
|
npubKey = self._DERtoPEM(npubKey, 'RSA PUBLIC KEY'); |
|
|
|
|
|
|
|
// Get signature from current certificate:
|
|
|
|
var data = new Buffer(der, 'hex'); |
|
|
|
var c = rfc3280.Certificate.decode(data, 'der'); |
|
|
|
var sig = c.signature.data; |
|
|
|
|
|
|
|
|
|
|
|
var jsrsaSig = new KJUR.crypto.Signature({ |
|
|
|
alg: type + 'withRSA', |
|
|
|
prov: 'cryptojs/jsrsa' |
|
|
|
}); |
|
|
|
//var key = new KJUR.RSAKey();
|
|
|
|
//key.readPublicKeyFromPEMString(npubKey);
|
|
|
|
//jsrsaSig.initVerifyByPublicKey(_npubKey.toString('hex'));
|
|
|
|
// http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Signature.html
|
|
|
|
// http://kjur.github.io/jsrsasign/api/symbols/RSAKey.html
|
|
|
|
|
|
|
|
// KEYUTIL:
|
|
|
|
// getKeyFromPublicPKCS8Hex
|
|
|
|
// getKeyFromPublicPKCS8PEM
|
|
|
|
// getKeyFromCSRPEM
|
|
|
|
// getKeyFromCSRHex
|
|
|
|
// getKey
|
|
|
|
// getHexFromPEM(sPEM, sHead)
|
|
|
|
// getKeyFromEncryptedPKCS8PEM(pkcs8PEM, passcode)
|
|
|
|
// getKeyFromPublicPKCS8Hex(pkcsPub8Hex)
|
|
|
|
// getKeyFromPublicPKCS8PEM(pkcsPub8PEM)
|
|
|
|
// getPEM(keyObjOrHex, formatType, passwd, encAlg)
|
|
|
|
// getRSAKeyFromPublicPKCS8PEM(pkcs8PubPEM)
|
|
|
|
// getKeyFromPublicPKCS8Hex(pkcsPub8Hex)
|
|
|
|
|
|
|
|
// http://kjur.github.io/jsrsasign/api/symbols/KEYUTIL
|
|
|
|
// var key = KJUR.KEYUTIL.getRSAKeyFromPublicPKCS8PEM(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.getHexFromPEM(npubKey, 'RSA PUBLIC KEY');
|
|
|
|
// var key = KJUR.KEYUTIL.getKeyFromPublicPKCS8PEM(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.getKey(npubKey, null, 'der');
|
|
|
|
// var key = KJUR.KEYUTIL.getKeyFromCSRHex(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.getKeyFromPublicPKCS8Hex(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.getRSAKeyFromPlainPKCS8Hex(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.getRSAKeyFromPublicPKCS8Hex(npubKey);
|
|
|
|
// var key = KJUR.KEYUTIL.parsePublicPKCS8Hex(npubKey);
|
|
|
|
|
|
|
|
// var key = KJUR.KEYUTIL.parsePublicRawRSAKeyHex(npubKey);
|
|
|
|
// key = KJUR.KEYUTIL.getKey(key);
|
|
|
|
|
|
|
|
jsrsaSig.initVerifyByPublicKey(key); |
|
|
|
|
|
|
|
// Create a To-Be-Signed Certificate to verify using asn1.js:
|
|
|
|
// Fails at Issuer:
|
|
|
|
var tbs = rfc3280.TBSCertificate.encode(c.tbsCertificate, 'der'); |
|
|
|
jsrsaSig.updateHex(tbs.toString('hex')); |
|
|
|
|
|
|
|
return jsrsaSig.verify(sig); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var verifier = crypto.createVerify('RSA-' + type); |
|
|
|
|
|
|
|
// Create a To-Be-Signed Certificate to verify using asn1.js:
|
|
|
|