Skip to content

NoMethodError: undefined method `at_xpath' for nil:NilClass #7

@aitherios

Description

@aitherios

I'm probably missing something.

Assuming I have the file example.xml with the content:

<?xml version="1.0"?>
<tag>test</tag>

Then I followed your example, and executed the code (replacing the cert, key files and password):

require "signer"

signer = Signer.new(File.read("example.xml"))
signer.cert = OpenSSL::X509::Certificate.new(File.read("cert.pem"))
signer.private_key = OpenSSL::PKey::RSA.new(File.read("key.pem"), "password")

signer.document.xpath("//u:Timestamp", { "u" => "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" }).each do |node|
  signer.digest!(node)
end

signer.document.xpath("//a:To", { "a" => "http://www.w3.org/2005/08/addressing" }).each do |node|
  signer.digest!(node)
end

signer.sign!(:security_token => true)

but I get NoMethodError: undefined method 'at_xpath' for nil:NilClass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions