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

Signature at root #47

Closed
nejcgorsic opened this issue Feb 19, 2024 · 6 comments
Closed

Signature at root #47

nejcgorsic opened this issue Feb 19, 2024 · 6 comments

Comments

@nejcgorsic
Copy link

nejcgorsic commented Feb 19, 2024

Hello everyone, joining after coming across the need for a signed XML (https://github.com/moov-io/signedxml?tab=readme-ov-file)
However (i hope this is the right channel and i apologize if it is not!)
I have an issue with .Sign() method.
This is the XML i am sending in:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
        <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
        <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
        <Reference URI="#test">
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
            <Transforms>
                <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
            </Transforms>
            <DigestValue>YWJjMTIz</DigestValue>
        </Reference>
    </SignedInfo>
    <SignatureValue>YWJjMTIz</SignatureValue>
    <KeyInfo>
        <X509Data>
            <X509Certificate>testtest</X509Certificate>
        </X509Data>
    </KeyInfo>
    <Object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="test">
        ...
ends with
</Object>
</Signature>

ANd i get this errror:
signedxml: unable to find Signature node
Not really sure what I should change?
According to the docs
Generating signed XML
It is expected that your XML contains the Signature element with all the parameters set (except DigestValue and SignatureValue).
Sorry, could not find any examples on the internet

Can Signature be on the root?

@adamdecaf
Copy link
Member

I think this is the same issue as #46

@RazaGR
Copy link

RazaGR commented Feb 19, 2024

it doesn't seems same as #46 , signedxml: unable to find Signature node maybe move Signature to header? I am not using this package so no idea.

@adamdecaf
Copy link
Member

adamdecaf commented Feb 19, 2024

Can you try out #48 and see if that helps? They may not be related. The other issue's XML is gone, but I thought part of that issue was a root level Signature element.

Edit: Are you using this signedxml package as part of another package?

@nejcgorsic
Copy link
Author

Hey @adamdecaf this PR helped with this issue. Works as intended now! Thank you. will this be merged?
I am using SignedXMl as part of another package

@adamdecaf
Copy link
Member

adamdecaf commented Feb 19, 2024

Yea I can get it merged. Thanks I was just curious who / how people are using the library. Can you share the package or is it private?

Edit: Released in https://github.com/moov-io/signedxml/releases/tag/v1.2.0

@nejcgorsic
Copy link
Author

Sorry, @adamdecaf it is private
Thank you for this!

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