Last active
December 18, 2015 23:19
-
-
Save yaronn/5860880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('xml-crypto') | |
, Dom = require('xmldom').DOMParser | |
, fs = require('fs') | |
var xml = fs.readFileSync('./windows_store_signature.xml', 'utf-8'); | |
var doc = new Dom({ignoreWhiteSpace: true}).parseFromString(xml); | |
xml = doc.firstChild.toString() | |
var signature = crypto.xpath(doc, "//*//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']")[0]; | |
var sig = new crypto.SignedXml(); | |
sig.keyInfoProvider = new crypto.FileKeyInfo("./windows_store_certificate.pem"); | |
sig.loadSignature(signature.toString()); | |
var result = sig.checkSignature(xml); | |
if (result) | |
console.log("signature is valid") | |
else | |
console.log("signature is invalid: " + sig.validationErrors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment