-
Notifications
You must be signed in to change notification settings - Fork 182
how to add Id
to KeyInfo tag ?
#482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you aware that this repository has discussions section activated? IMHO all of these could have been started as questions at discussions instead of issues:
Some of those issues were resolved by you with comment like "nevermind"/"got working". If you had an issue why not share solution with others who might have tried to already spend time to replicate your problem with short info that you provided. |
both closed issues answered with more info to help people |
IMHO this issue can be closed because this is actually "part of" problem described at issue: which in turn is duplicate of
|
Hi @sibelius, have you ever succeeded in doing this? I'm having the same problem with Signed XML. |
Not with nodejs, we moved to Java for this |
@sibelius @matheusinfo Has two way to achieve this. const SignedXml = require("xml-crypto").SignedXml;
const fs = require("fs");
const xml = "<root><item>Some content</item></root>";
const sig = new SignedXml({
privateKey: fs.readFileSync("path/to/your/privateKey.pem"),
publicCert: fs.readFileSync("path/to/your/publicCert.pem"),
keyInfoAttributes: { Id: "key-info-id" } // Add your Id attribute here
});
// Add references, etc.
sig.addReference({
xpath: "//*[local-name(.)='item']"
});
// Compute the signature
// If you want the "ds" prefix for KeyInfo (as in <ds:KeyInfo>),
// provide it in the computeSignature options.
sig.computeSignature(xml, {
prefix: "ds" // This will make the KeyInfo tag <ds:KeyInfo>
});
const signedXml = sig.getSignedXml();
console.log(signedXml); Second one (Via Instance Property) const SignedXml = require("xml-crypto").SignedXml;
const fs = require("fs");
const xml = "<root><item>Some content</item></root>";
const sig = new SignedXml({
privateKey: fs.readFileSync("path/to/your/privateKey.pem"),
publicCert: fs.readFileSync("path/to/your/publicCert.pem")
});
sig.keyInfoAttributes = { Id: "key-info-id" }; // Set your Id attribute here
sig.addReference({
xpath: "//*[local-name(.)='item']"
});
sig.computeSignature(xml, {
prefix: "ds"
});
const signedXml = sig.getSignedXml();
console.log(signedXml); |
The text was updated successfully, but these errors were encountered: