Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C14N extremely slow on large nodes + potential workaround #220

Open
gboor opened this issue Nov 18, 2020 · 0 comments
Open

C14N extremely slow on large nodes + potential workaround #220

gboor opened this issue Nov 18, 2020 · 0 comments

Comments

@gboor
Copy link

gboor commented Nov 18, 2020

For some project I have to send a SOAP document containing many dozens of thousands of points of data. When trying to sign it using the WSSE library (also by @robrichards), I ran into a very old PHP issue that was never resolved;

https://bugs.php.net/bug.php?id=53655

Basically, sending the document with 43000 data points took well over an hour, just to canonilize. And we're looking at many times that.

The known PHP bug also states that calling C14N on a DomDocument instead of a DomNode is near instant. This caused me to devise the following workaround. In XMLSecurityDSig.php on line 296, replace;

        return $node->C14N($exclusive, $withComments, $arXPath, $prefixList);

with

        $doc = new DOMDocument();
        $newnode = $doc->importNode($node, true);
        $doc->appendChild($newnode);

        return $doc->C14N($exclusive, $withComments, $arXPath, $prefixList);

Now the document canonilization is near instant and I've verified that both methods output the exact same strings.

Since this is a very hacky workaround for a problem that should honestly be solved in PHP itself, I can understand that this should not go into this library as a patch. But if there is any interest, I'm happy to create an PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant