xml-crypto icon indicating copy to clipboard operation
xml-crypto copied to clipboard

addReference with empty URI i.e. `URI=""`

Open jaikathuria opened this issue 2 years ago • 5 comments

Couldn't find a way to sign the whole XML document and have the URL as an empty string while adding the reference

Reference URI=""

jaikathuria avatar Nov 07 '22 13:11 jaikathuria

Went through the code and was able to find the way to sign the document and add the reference with URI=""

The addReference method takes the 7th argument as isEmptyUri and when it's value is true the URI is saved as "" which was the desired output.

It can be achieve something like

sign.addReference("/*", undefined, undefined, undefined, undefined, undefined, true);

jaikathuria avatar Nov 07 '22 19:11 jaikathuria

@LoneRifle Probably you can help here.

Suggestion: The 4th argument in addReference method takes uri as input and if the argument's value is passed as "" it should automatically set isEmptyUri to be true. That would make the functionality easier to achieve with a cleaner code.

If you agree, I would be happy to implement it.


Also, It would be nice to add this to the documentation. Signing the XML document with reference URI="" is one of the most basic requirements. And the library supports it, it would be really nice to add it to the README. Willing to take the documentation task as well

jaikathuria avatar Nov 07 '22 19:11 jaikathuria

I'm having issues when using isEmptyUri=true.

When I try isEmptyUri = false I can verify my signature and it is all good but,

When try isEmptyUri = true I get the bellow error when verifying the signature

VERIFY ERROR: 'invalid signature: for uri calculated digest is 4jyM3Mma3Wo1zTUT8njmv9wHWVnsf2cz4bAS2POf6Do= but the xml to validate supplies digest cJ1B4QVSGSggHteZGcwznrpo5aZy+3L+tK3ZF9PXwj8='

@jaikathuria are you having the same issue?

Rodrigobanselmo avatar Nov 11 '22 10:11 Rodrigobanselmo

Not actually. I had to sign the XML to be verified by an external library and I was only able to validate it with isEmptyUri=true.

I didn't try to verify the XML myself though.

How you are trying to sign and verify, I might be able to assist.

jaikathuria avatar Nov 13 '22 10:11 jaikathuria

Feel free to put up a PR that includes some better documentation about this or that improves the user experience.

cjbarth avatar May 29 '23 18:05 cjbarth