-
Notifications
You must be signed in to change notification settings - Fork 176
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
Failed to generate a correct signature #484
Comments
I did not test (run) your code but one thing caught my I immediately. Quote from your issue report
xml-crypto does not apply implicitly sig.addReference({
xpath: "/*",
digestAlgorithm: 'http://www.w3.org/2000/09/xmldsig#sha1',
transforms: [
'http://www.w3.org/2000/09/xmldsig#enveloped-signature',
'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'
],
isEmptyUri: false,
}); See more info from these two comments from another issue: |
@srd90 : Thank you for replying, can you help me with a snippet that can generate a signed xml same as above |
Did you add that transformation and test your stuff? FWIW, if you are conserned about having that extra transformation explicitly listed at resulting xml (which means that your signature block doesn't look exactly same with what you want) you shouldn't (be conserned). You'd just happen to list it explicitly instead of relying to implicit transform. FWIW2: you cannot make that (required) extra transform vanish unless you introduce a PR to xml-crypto repo which modify implementation (#212 (comment)) to use that transform implicitly (unless there aren't any explicitly listed C14N)...i.e. unless you make stuff work symmetrically with validation and how other libs seems to apply implicit transforms.
I cannot. It is not possible with current (6.0.0) and past versions of xml-crypto (if your ultimate goal is to have 1:1 same transforms list at resulting XML as your sample XML). |
I cloned the repo, I change snippets to fit my needs and it's working perfectly
export class C14nCanonicalizationEnveloped extends C14nCanonicalization {
constructor() {
super();
this.includeComments = false;
}
getAlgorithmName() {
return "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
}
}
"http://www.w3.org/2000/09/xmldsig#enveloped-signature": c14n.C14nCanonicalizationEnveloped, |
So you registered totally different implementation for algorithm It ( xml-crypto/src/enveloped-signature.ts Lines 10 to 61 in 2120172
but your modification registered implementation which is xml-crypto/src/c14n-canonicalization.ts Lines 10 to 281 in 2120172
Its usually bad thing / troubles ahead when you do such things. Obviously your problem was just the lack of C14N after enveloped signature transformation when signing. You could have added that explicitly to the tranformations list or you could have fixed xml-crypto to apply that implicitly also during signing as other libs seems to do if it is not explicitly listed instead of redefining implementation of |
Can someone help me to generate same signature like this in nodejs using xml-crypto:
I have two keys :
This is my try in js
The text was updated successfully, but these errors were encountered: