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

digest do not match #46

Open
RazaGR opened this issue Jan 25, 2024 · 7 comments
Open

digest do not match #46

RazaGR opened this issue Jan 25, 2024 · 7 comments

Comments

@RazaGR
Copy link

RazaGR commented Jan 25, 2024

I get error The digest of soapBody was not correct.

any idea @adamdecaf why it could happen?

	signer, err := signedxml.NewSigner(xmlString)
	signedXML, err := signer.Sign(privateKey)
</Reference>
  <Reference URI="#soapBody">
    <Transforms>
      <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <DigestValue>TLcN2ydc2+DlKl5IEzl1PDHTf4E=</DigestValue>
  </Reference>
@adamdecaf
Copy link
Member

Is there more to the Signature element? Can you compare the output to another library? We know the library doesn't fully support all transforms and c14n specifications.

@RazaGR
Copy link
Author

RazaGR commented Jan 26, 2024

here is full xml https://pastecode.io/s/33vn08oc
I am using xmlsec1 to verify and have used xmlsec1 which creates a valid digest values

xmlsec1 --sign --output original.xml --privkey-pem private.key,name.crt  signed.xml

could you please recommend which other library? Thanks

@adamdecaf
Copy link
Member

I can't see that paste. Is xmlsec1 transforming the xml differently than this library? My assumption is the issue comes from moov-io/signedxml missing some of the c14n logic.

@RazaGR
Copy link
Author

RazaGR commented Jan 30, 2024

DigestValue is different with xmlsec1
paste https://pastecode.io/s/wjet5d6h

@nejcgorsic
Copy link

This seems like it has the same issue and not resolved, as #47?

@printesoi
Copy link

I still get this error with signedxml v1.2.1. The following XML file with signature was generated with xmlsec1, I can sucessfully verify it with xmlsec1 --verify --insecure test.xml and with https://tools.chilkat.io/xmlDsigVerify.cshtml , but when using:

validator, _ := signedxml.NewValidator(xmlData)
xmlv, err := validator.ValidateReferences()

I get Calculated digest does not match the expected digestvalue of R66/Sid+tFYdFog0cjhSiagTnTZLN6Njs/Y7YZtH1mc=

@adamdecaf
Copy link
Member

I get the same error with your fork of github.com/m29h/xml but those libraries are improving marshaling. I tried reading and writing using your fork without much luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants