Skip to content

duplicate reference in signature #165

Closed
@wilson-6731

Description

@wilson-6731

I'm getting a weird bug where the reference tag is duplicated whenever my frontend calls the backend to generate a SAML assertion. It occasionally happens and breaks signature verification regardless if I trim the excess reference nodes . Can anyone point me in the right direction on how to resolve this?
Thanks.

Here is the code snippet that I have performing the xml signature. Let me know if I need to post more information.

function signAssertion(assertion) {
  signer.addReference("//*[local-name(.)='Assertion']", ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/2001/10/xml-exc-c14n#'], 'http://www.w3.org/2001/04/xmlenc#sha256')
  signer.signingKey = fs.readFileSync('./idp_priv.pem')
  signer.signatureAlgorithm = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
  signer.keyInfoProvider = new KeyProvider()
  signer.computeSignature(assertion, {
    location: {
      reference: '/saml:Assertion/saml:Issuer',
      action: 'after'
    }
  })
  return signer.getSignedXml()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions