Skip to content

Commit 48bb282

Browse files
metsmamrts
authored andcommitted
Fix tests with recent libraries
WE2-833 Signed-off-by: Raul Metsma <[email protected]>
1 parent ce6a44b commit 48bb282

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/validator/AuthTokenValidatorImpl.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ private function validateToken(WebEidAuthToken $token, string $currentChallengeN
136136
throw new AuthTokenParseException("'unverifiedCertificate' field is missing, null or empty");
137137
}
138138
$subjectCertificate = new X509();
139-
if (!$subjectCertificate->loadX509($token->getUnverifiedCertificate())) {
139+
$loaded = false;
140+
try {
141+
$loaded = $subjectCertificate->loadX509($token->getUnverifiedCertificate());
142+
} catch (Throwable $e) {
143+
}
144+
if (!$loaded) {
140145
throw new CertificateDecodingException("'unverifiedCertificate' decode failed");
141146
}
142147

tests/validator/certvalidators/SubjectCertificateNotRevokedValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function testWhenOcspResponseHasInvalidSignatureThenThrows(): void
148148
public function testWhenOcspResponseHasInvalidResponderCertThenThrows(): void
149149
{
150150
$this->expectException(UserCertificateOCSPCheckFailedException::class);
151-
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Unable to perform ASN1 mapping");
151+
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Unable to decode BER");
152152
$validator = self::getSubjectCertificateNotRevokedValidatorWithAiaOcspUsingResponse(
153153
pack("c*", ...self::buildOcspResponseBodyWithInvalidResponderCert())
154154
);
@@ -158,7 +158,7 @@ public function testWhenOcspResponseHasInvalidResponderCertThenThrows(): void
158158
public function testWhenOcspResponseHasInvalidTagThenThrows(): void
159159
{
160160
$this->expectException(UserCertificateOCSPCheckFailedException::class);
161-
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Could not decode OcspResponse->responseBytes->response");
161+
$this->expectExceptionMessage("User certificate revocation check has failed: Exception: Trying to access array offset on null");
162162
$validator = self::getSubjectCertificateNotRevokedValidatorWithAiaOcspUsingResponse(
163163
pack("c*", ...self::buildOcspResponseBodyWithInvalidTag())
164164
);

0 commit comments

Comments
 (0)