moov-io/signedxml

digest do not match

Opened this issue · 7 comments

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>

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.

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

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.

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

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

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=

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.