I'm trying to address the root element with the namespace and providing a reference to the library xml-crypto.
I'm not giving the path correctly, please advise. Objective is to sign the document so the signature can be inserted right after the tag <samlp:Response
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="efedb3b0-909f-4b39-b8c0-57427ee8dc83" Version="2.0" IssueInstant="2019-11-08T15:34:51.272Z">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">http://www.example.com</saml:Issuer>
</samlp:Response>
nodeJS code
var SignedXml = require('xml-crypto').SignedXml, fs = require('fs');
var sig = new SignedXml();
sig.addReference("//*[local-name(.)='samlp:Response']");
sig.signingKey = fs.readFileSync(__dirname + "/client.pem");
sig.computeSignature(xml);
fs.writeFileSync(__dirname + "/signed.xml", sig.getSignedXml());
Attempts
sig.addReference("//samlp:Response");
Error: Cannot resolve QName samlp
it worked fine at https://www.freeformatter.com/xpath-tester.html though