I need to sign an xml for Nfse, I'm using the xml-crypto librarian, however I get the return that the signature is incorrect. Can someone tell me another javascript library? Here's a snippet of my code with xml-crypto
var SignedXml = require('xml-crypto').SignedXml;
var sig = new SignedXml()
sig.keyInfoProvider = new FileKeyInfo(fs.readFileSync('./public/remessas/chave.cer'))
sig.addReference("//*[local-name(.)='InfDeclaracaoPrestacaoServico']",
['http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315' ]
)
sig.signingKey = fs.readFileSync('./public/agt.txt');
sig.computeSignature(xml, {
location: {
reference: "//*[local-name(.)='InfDeclaracaoPrestacaoServico']",
action: "after"
}
});
var xmlFinal = sig.getSignedXml()