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

Support XAdES #54

Open
ningzhang422 opened this issue Sep 20, 2022 · 15 comments
Open

Support XAdES #54

ningzhang422 opened this issue Sep 20, 2022 · 15 comments

Comments

@ningzhang422
Copy link

Is it possible to extend this gems to support XAdES Signature ?

@benoist
Copy link
Owner

benoist commented Sep 20, 2022

Hi,

I'm sure it will be possible, but unfortunately I won't be able to implement it due to time constrictions.
I personally don't use this gem anymore, but I'm happy to take pull requests.

@ningzhang422
Copy link
Author

This is my propose
I really want to contribute the part XAdES
Please give us some suggestions to start the dev in this gem.

@ningzhang422
Copy link
Author

If i'm not wrong
xmldsig can only sign the xml of the envoloped structure
We need to expand the development to suppport the envoloping structure
please confirm that thank you

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

It supports a few transforms. Enveloped signature is one of them.
It also supports xpath. I would assumes XAdES would be another transform?
I haven't read the spec, so I could be wrong

@ningzhang422
Copy link
Author

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

So you need the canonicalization and the XPath transform. They are already present...

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

#25

@ningzhang422
Copy link
Author

Transform => OK
But when the reference point to inside signature (Enveloping signature)
I got a error message :
ruby/3.0.0/gems/xmldsig-0.7.0/lib/xmldsig/reference.rb:42:in referenced_node: Could not find the referenced node IHEManifest

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

Do you have a gist with reproducable steps?

@ningzhang422
Copy link
Author

Thank you for your quick answer

image
In the image, Step 1 and Step 2 have passed already. We are in step 3 to sign two references make DigestValues and SignatureValue

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

Should it not be ID instead of Id on the manifests?

https://github.com/benoist/xmldsig/blob/master/lib/xmldsig/reference.rb#L37

@ningzhang422
Copy link
Author

ningzhang422 commented Sep 21, 2022

When I try to sign a content which is separate from node signature.
Which means making a Detached Signature.
I got a error like below
/nemoweb/vendor/ruby/3.0.0/gems/nokogiri-1.11.6-x86_64-linux/lib/nokogiri/xml/document.rb:75:in read_memory: 2:1: FATAL: Extra content at the end of the document (Nokogiri::XML::SyntaxError)
image
Could you please tell me if this error is due to gem not supported Detached Signature ?

@benoist
Copy link
Owner

benoist commented Sep 21, 2022

It's really hard to help if you don't have an example in code :)

Perhaps you can add a fixture with to the specs and try to write a spec for it in a pull request..

Just like here with the transform that you need

https://github.com/benoist/xmldsig/blob/master/spec/fixtures/signed_xml-exc-c14n%23with_comments.xml

@ningzhang422
Copy link
Author

I've been trying to write test data for the past two days.
I found that this gem can't take the value in the attachment with 'reference'.
image
Do you have any suggestions please
How to write test data for such scenarios ?

@xxswingxx
Copy link

Thank you for your quick answer

image In the image, Step 1 and Step 2 have passed already. We are in step 3 to sign two references make DigestValues and SignatureValue

Hey @ningzhang422 , I'm not sure if you've figured it out already but you can indicate the name of the the Id attribute so matches your case. By default this gem supports "ID" but in your screenshots it appears as "Id", so you should be able to define it using the id_attrduring the initialization:

unsigned_document = Xmldsig::SignedDocument.new(unsigned_xml, id_attr: 'Id')
signed_xml = unsigned_document.sign(private_key)

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

No branches or pull requests

3 participants