Skip to content

Commit 87aceb7

Browse files
erkkiarusmrts
authored andcommitted
Updates tests for changed test SK OCSP responder certificate
* Marked testWhenCertificateIsRevokedThenOcspCheckWithDesignatedOcspServiceFails test as skipped; * Marked testWhenValidDesignatedOcspResponderConfigurationThenSucceeds test as skipped; * Marked testWhenValidOcspNonceDisabledConfigurationThenSucceeds test as skipped; * Changed PHP tests to use phpseclib/phpseclib version 30.0.19 (CVE-2023-27560); * Changed PHP tests to use guzzlehttp/psr7 version 2.4.5 (CVE-2023-29197). Signed-off-by: Erkki Arus <[email protected]>
1 parent f619e57 commit 87aceb7

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
}
3333
],
3434
"require": {
35-
"phpseclib/phpseclib": "3.0.14",
36-
"guzzlehttp/psr7": "2.4.3",
35+
"phpseclib/phpseclib": "3.0.19",
36+
"guzzlehttp/psr7": "2.4.5",
3737
"web-eid/ocsp-php": "1.0.0",
3838
"psr/log": "^3.0"
3939
},
4040
"scripts": {
41-
"fix-php": ["prettier src/**/* --write", "prettier examples/src/* --write"]
41+
"fix-php": ["prettier src/**/* --write", "prettier examples/src/* --write"],
42+
"test": "phpunit"
4243
}
4344
}

src/util/AsnUtil.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,18 @@ public static function isSignatureInAsn1Format(string $signature): bool
4040

4141
// ASN.1 format: 0x30 b1 0x02 b2 r 0x02 b3 s.
4242
// Note: unpack() returns an array indexed from 1, not 0.
43+
if(!isset($sigByteArray[1]) ||
44+
!isset($sigByteArray[2]) ||
45+
!isset($sigByteArray[3]) ||
46+
!isset($sigByteArray[4])) {
47+
return false;
48+
}
4349
$b1 = $sigByteArray[2];
4450
$b2 = $sigByteArray[4];
51+
if(!isset($sigByteArray[5 + $b2]) ||
52+
!isset($sigByteArray[6 + $b2])) {
53+
return false;
54+
}
4555
$b3 = $sigByteArray[6 + $b2];
4656

4757
return $sigByteArray[1] == 0x30 // Sequence tag

tests/validator/AuthTokenCertificateTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public function testWhenCertificateIsRevokedThenOcspCheckFails(): void
247247

248248
public function testWhenCertificateIsRevokedThenOcspCheckWithDesignatedOcspServiceFails(): void
249249
{
250+
$this->markTestSkipped("A new designated test OCSP responder certificate was issued whose validity period no longer overlaps with the revoked certificate");
250251
$this->mockDate("2020-01-01");
251252

252253
$validatorWithOcspCheck = AuthTokenValidators::getAuthTokenValidatorWithDesignatedOcspCheck();

tests/validator/certvalidators/SubjectCertificateNotRevokedValidatorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function testWhenValidAiaOcspResponderConfigurationThenSucceeds(): void
6666

6767
public function testWhenValidDesignatedOcspResponderConfigurationThenSucceeds(): void
6868
{
69+
$this->markTestSkipped("As new designated test OCSP responder certificates are issued more frequently now, it is no longer feasible to keep the certificates up to date");
6970
$this->expectNotToPerformAssertions();
7071

7172
$ocspServiceProvider = OcspServiceMaker::getDesignatedOcspServiceProvider();
@@ -75,6 +76,7 @@ public function testWhenValidDesignatedOcspResponderConfigurationThenSucceeds():
7576

7677
public function testWhenValidOcspNonceDisabledConfigurationThenSucceeds(): void
7778
{
79+
$this->markTestSkipped("As new designated test OCSP responder certificates are issued more frequently now, it is no longer feasible to keep the certificates up to date");
7880
$this->expectNotToPerformAssertions();
7981

8082
$ocspServiceProvider = OcspServiceMaker::getDesignatedOcspServiceProvider(false);
@@ -156,7 +158,7 @@ public function testWhenOcspResponseHasInvalidResponderCertThenThrows(): void
156158
public function testWhenOcspResponseHasInvalidTagThenThrows(): void
157159
{
158160
$this->expectException(UserCertificateOCSPCheckFailedException::class);
159-
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Could not decode OcspResponse->responseBytes->responseType");
161+
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Could not decode OcspResponse->responseBytes->response");
160162
$validator = self::getSubjectCertificateNotRevokedValidatorWithAiaOcspUsingResponse(
161163
pack("c*", ...self::buildOcspResponseBodyWithInvalidTag())
162164
);

0 commit comments

Comments
 (0)