Skip to content

Commit 7e03c42

Browse files
committed
Cover a PHP signature that pins inclusive namespace prefixes
A PHP round trip cannot prove this half: our own reader honours whatever PrefixList it is handed, so only a conformant peer re-canonicalizing from the declaration can tell us the pinned list and the digests agree. Emitting a wrong PrefixList makes WSS4J answer valid:false, so the row fails for its own reason.
1 parent 775a174 commit 7e03c42

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

tests/Support/Wsse.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static function sign(
3838
?array $parts = null,
3939
?string $inputXml = null,
4040
int $timestampTtl = 300,
41+
bool $inclusivePrefixes = false,
4142
): string {
4243
$soapVersion ??= SoapVersion::Soap12;
4344
$document = Document::fromXmlString($inputXml ?? Oracle::sampleEnvelope());
@@ -56,6 +57,9 @@ public static function sign(
5657
if ($parts !== null) {
5758
$signature = $signature->withParts($parts);
5859
}
60+
if ($inclusivePrefixes) {
61+
$signature = $signature->withInclusivePrefixes();
62+
}
5963
$signature($context);
6064

6165
return $document->toXmlString();

tests/Wsse/CanonicalizationInteropTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ public function test_php_inclusive_c14n_signature_is_accepted_by_wss4j(): void
3737
self::assertJsonStringEqualsJsonString('{"valid":true}', $response['body']);
3838
}
3939

40+
/**
41+
* The outbound half of the InclusiveNamespaces feature. A PHP round trip cannot prove this: our own reader
42+
* honours whatever PrefixList it is handed, so only a conformant peer re-canonicalizing from the
43+
* declaration can tell us the pinned list and the digests actually agree.
44+
*/
45+
public function test_php_signature_pinning_inclusive_prefixes_is_accepted_by_wss4j(): void
46+
{
47+
$signed = Wsse::sign(inclusivePrefixes: true);
48+
49+
self::assertStringContainsString('InclusiveNamespaces', $signed);
50+
self::assertStringContainsString('PrefixList=', $signed);
51+
52+
$response = Oracle::post('/verify', $signed);
53+
54+
self::assertSame(200, $response['status']);
55+
self::assertJsonStringEqualsJsonString('{"valid":true}', $response['body']);
56+
}
57+
4058
public function test_wss4j_inclusive_c14n_signature_is_accepted_by_php(): void
4159
{
4260
$javaSigned = Oracle::post('/sign?c14n=INCLUSIVE&disableBsp=true', Oracle::sampleEnvelope())['body'];

0 commit comments

Comments
 (0)