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

NilClass error when signing xml #55

Open
alanBAguero opened this issue Sep 27, 2022 · 2 comments
Open

NilClass error when signing xml #55

alanBAguero opened this issue Sep 27, 2022 · 2 comments

Comments

@alanBAguero
Copy link

alanBAguero commented Sep 27, 2022

This is the script I used to sign:

unsigned_xml = File.read("/home/path/unsigned.xml"); 0
private_key = OpenSSL::PKey::RSA.new(File.read("/home/path/certificates/alice.key")); 0
certificate = OpenSSL::X509::Certificate.new(File.read("/home/path/alice.crt")); 0
unsigned_document = Xmldsig::SignedDocument.new(unsigned_xml, id_attr: "Id"); 0
signed_xml = unsigned_document.sign(private_key)

But I'm getting a NoMethodError (undefined method remove' for nil:NilClass)`.
Do you know what might be the issue? Sorry, this is my first time working with XMLs and I'm kind of stuck
with this issue. If you could please help me, I'd appreciate it a lot!

Here's a gist with unsigned xml, certificate and private key: https://gist.github.com/alanBAguero/62d77ee45f14f15a16b376e08118ee18

@alanBAguero
Copy link
Author

The xml has the following structure:

- rDE
  - dVerFor
  - DE, Id="some-id"  # I need to sign these fields
  - Signature # "some-id" is specified on URI attribute of Reference tag

@Guistoff081
Copy link

I am stuck with the same error:

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

raises NoMethodError:
undefined method `remove' for nil:NilClass

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

Successfully merging a pull request may close this issue.

2 participants