Hi, I have a problem with signing xml document.
My code to sign is:
// FIRMAR LA DATA
$docAFirmar = new DOMDocument();
$docAFirmar->formatOutput = true;
$docAFirmar->encoding = 'UTF-8';
$docAFirmar->loadXML($dataAFirmar);
$objDSig = new XMLSecurityDSig();
$objDSig->setCanonicalMethod(XMLSecurityDSig::C14N);
$objDSig->addReference($docAFirmar, XMLSecurityDSig::SHA1,
array('
http://www.w3.org/2000/09/xmldsig#enveloped-signature',
XMLSecurityDSig::C14N), array('force_uri' => true));
objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
$sslPath = 'C:\\xampp\\htdocs\\Efactura\\Certificados\\';
$objKey->passphrase = "mypass";
$objKey->loadKey($sslPath . PRIVATE_KEY_RSA, TRUE);
$objDSig->sign($objKey);
$objDSig->add509Cert(file_get_contents($sslPath . CERT_FILE));
$objDSig->appendSignature($docAFirmar->documentElement);
$signedDoc = $docAFirmar->saveXML();
I save the $signedDoc data in a file called "doc_signed.xml"
When I send this data to a secured webservice the result is "error in signed data".
I had no idea why they refused my signed doc, so I programmed a simple sign and verify in charp.
When I sign the document with csharp and sign the same document with xmlseclibs, the DigestValue and SignatureValue are differents. Why ? I use the same certificate (public and private key).
When I verify in csharp the signed doc in csharp the result is ok.
When I verify in xmlseclibs the result is wrong.
I am using version xmlseclibs number 1.3.1-dev
I can send you the 3 documents (doc before sign, doc signed with xmlseclibs, doc signed with csharp).
Thanks, Juan.