moov-io / signedxml

pure go library for processing signed XML documents
MIT License
52 stars 44 forks source link

digest do not match #46

Open RazaGR opened 7 months ago

RazaGR commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

nejcgorsic commented 6 months ago

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

printesoi commented 5 months ago

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 commented 5 months ago

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.