Skip to content

Undefined method xpath for String #57

@xxswingxx

Description

@xxswingxx

Hi, I'm having to sign an xml with the canonicalization as the first transformation:

...
   <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature">
    <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
      <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
      <ds:Reference Id="Reference-7e6f3481-4acc-47de-90fd-67878ad15e8e" Type="http://www.w3.org/2000/09/xmldsig#Object" URI="">
        <ds:Transforms>
          <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
          <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
          <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
            <ds:XPath xmlns:ds="http://www.w3.org/2000/09/xmldsig#">not(ancestor-or-self::ds:Signature)</ds:XPath>
          </ds:Transform>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
        <ds:DigestValue>2hkA19hRLUHwVlkmokFcnIUGv96nrhi8ZIgSoYuTNJ98wgoKE8iT1UzdgGJzDQ79+3LjjH6qzZEMwSYewyVNcg==</ds:DigestValue>
...

However it seems that by applying that first canonicalization as the first transformation node, the @node variable from https://github.com/benoist/xmldsig/blob/master/lib/xmldsig/transforms.rb#L7 is converted from a Nokogiri::XML::Element to a regular String which makes all the subsequent transformation to fail.

Given my inexperience with signing xml I'm not sure if applying the canonicalization as the first transformation is a regular or correct use case or if it's just unsupported by the gem.

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