Skip to content
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

addReference with empty URI i.e. URI="" #268

Open
jaikathuria opened this issue Nov 7, 2022 · 5 comments
Open

addReference with empty URI i.e. URI="" #268

jaikathuria opened this issue Nov 7, 2022 · 5 comments

Comments

@jaikathuria
Copy link

jaikathuria commented Nov 7, 2022

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 jaikathuria changed the title How to create enveloped signature and sign the whole document i.e. have URI="" Enveloped signature and sign the whole document i.e. have URI="" Nov 7, 2022
@jaikathuria jaikathuria changed the title Enveloped signature and sign the whole document i.e. have URI="" addReference with empty URI i.e. URI="" Nov 7, 2022
@jaikathuria
Copy link
Author

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
Copy link
Author

jaikathuria commented Nov 7, 2022

@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

@Rodrigobanselmo
Copy link

Rodrigobanselmo commented Nov 11, 2022

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?

@jaikathuria
Copy link
Author

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.

@cjbarth
Copy link
Contributor

cjbarth commented May 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants