我试图用命名空间寻址根元素,并提供对库xml-crypto的引用。
我没有正确给出路径,请告知。目的是对文档进行签名,以便可以在标签results = [];
db.collection('schedules').find().forEach(function(d) { results.push(d); });
<samlp:Response
nodeJS代码
<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>
尝试
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());
错误:无法解析QName samlp