From bd47501f0d452816e7957d2e43d5c32c6001f50b Mon Sep 17 00:00:00 2001 From: njake Date: Wed, 4 Dec 2019 16:28:23 +0200 Subject: [PATCH] FIX missing InclusiveNamespaces PrefixList from Java + Apache WSS4J (#205) * FIX missing InclusiveNamespaces PrefixList when Canonicalize Soap message from Java + Apache WSS4J example: parse php array('cor', 'mod', 'soapenv') for canonicalizeData function call from xml below * whitespace fixed --- src/XMLSecurityDSig.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/XMLSecurityDSig.php b/src/XMLSecurityDSig.php index c9063d0f..d032b264 100644 --- a/src/XMLSecurityDSig.php +++ b/src/XMLSecurityDSig.php @@ -314,10 +314,22 @@ public function canonicalizeSignedInfo() if ($signInfoNode = $nodeset->item(0)) { $query = "./secdsig:CanonicalizationMethod"; $nodeset = $xpath->query($query, $signInfoNode); + $prefixList = null; if ($canonNode = $nodeset->item(0)) { $canonicalmethod = $canonNode->getAttribute('Algorithm'); + foreach ($canonNode->childNodes as $node) + { + if ($node->localName == 'InclusiveNamespaces') { + if ($pfx = $node->getAttribute('PrefixList')) { + $arpfx = array_filter(explode(' ', $pfx)); + if (count($arpfx) > 0) { + $prefixList = array_merge($prefixList ? $prefixList : array(), $arpfx); + } + } + } + } } - $this->signedInfo = $this->canonicalizeData($signInfoNode, $canonicalmethod); + $this->signedInfo = $this->canonicalizeData($signInfoNode, $canonicalmethod, null, $prefixList); return $this->signedInfo; } }