I have sign the xml for send in soap request. I use the xmlseclibs. The lib sign correctly xml, but not the way I need it.
The Xmls: https://pastebin.com/qyA8fmbi
My code for sign the Xml:
use RobRichards\XMLSecLibs\XMLSecurityDSig;
use RobRichards\XMLSecLibs\XMLSecurityKey;
function signXML($xml) {
$doc = new DOMDocument('1.0','UTF-8');
$doc->loadXML($xml);
$objDSig = new XMLSecurityDSig('');
$objDSig->setCanonicalMethod(XMLSecurityDSig::C14N);
$objDSig->addReference(
$doc,
XMLSecurityDSig::SHA1,
['http://www.w3.org/2000/09/xmldsig#enveloped-signature',
'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'],
["force_uri"=>true]
);
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
$privkey = 'cert_pem/privkey.pem';
$objKey->loadKey($privkey, TRUE);
$objDSig->sign($objKey);
$pubkey = 'cert_pem/mycert.pem';
$objDSig->add509Cert(file_get_contents($pubkey));
$objDSig->appendSignature($doc->documentElement);
return $doc->saveXML();
}