Open tarlanpayment opened 4 years ago
I spent much time with the same issue and finally found what was wrong, in case it helps anyone.
The problem is that canonicalization must happen AFTER the signature node is added to the document. Otherwise, document namespaces won't be added to the SignedInfo while canonicalization occurs and the SingatureValue will be wrong.
In your code, instead of signing first and then appending the signature:
$objDSig->sign($objKey);
$objDSig->add509Cert($key['cert']);
$objDSig->appendSignature($doc->documentElement);
dd($doc->saveXML());
you can append and sing all in one method, using the second parameter:
$objDSig->sign($objKey, $doc->documentElement);
$objDSig->add509Cert($key['cert']);
dd($doc->saveXML());
This worked for me.
I spent much time with the same issue and finally found what was wrong, in case it helps anyone.
The problem is that canonicalization must happen AFTER the signature node is added to the document. Otherwise, document namespaces won't be added to the SignedInfo while canonicalization occurs and the SingatureValue will be wrong.
In your code, instead of signing first and then appending the signature:
$objDSig->sign($objKey); $objDSig->add509Cert($key['cert']); $objDSig->appendSignature($doc->documentElement); dd($doc->saveXML());
you can append and sing all in one method, using the second parameter:
$objDSig->sign($objKey, $doc->documentElement); $objDSig->add509Cert($key['cert']); dd($doc->saveXML());
This worked for me.
For me to
Hi. Thanks for good extension. My code generates invalid signature, I tested when I check with https://tools.chilkat.io/xmlDsigVerify.cshtml, also I have right xml which must be generated, but they are not equal.