robrichards / xmlseclibs

A PHP library for XML Security
BSD 3-Clause "New" or "Revised" License
387 stars 181 forks source link

Error "Uncaught Error: Call to a member function item" #186

Open erwo opened 5 years ago

erwo commented 5 years ago

Hi, in apache log i can find the following error messages: [php7:warn] PHP Warning: DOMXPath::query(): Node From Wrong Document in ... PHP Fatal error: Uncaught Error: Call to a member function item() on boolean in XMLSecurityDSig.php:306

My Code is: require 'xmlseclib/XMLSecurityKey.php'; require 'xmlseclib/XMLSecurityDSig.php'; require 'xmlseclib/XMLSecEnc.php'; require 'xmlseclib/Utils/XPath.php';

use RobRichards\XMLSecLibs\XMLSecurityDSig; use RobRichards\XMLSecLibs\XMLSecurityKey; use RobRichards\XMLSecLibs\XMLSecEnc; use RobRichards\XMLSecLibs\Utils; $doc = new DOMDocument(); $doc->loadXML($postcontent);

$objXMLSecDSig = new XMLSecurityDSig(); $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); $objDSig = $objXMLSecDSig->locateSignature($doc); $objXMLSecDSig->canonicalizeSignedInfo(); $objKey = $objXMLSecDSig->locateKey(); $objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);

And so on, it seems to break at the Function "setCanonicalMethod"

The relevant parts of the xml File are: ... <ds:Signature` xmlns:ds="http://www.w3.org/2000/09/xmldsig#">

de...= cWxOQ== MIIDkD...ig==