Skip to content

Commit 952cd8c

Browse files
fix(signature): return 422 for certificate validation failures
Differentiate certificate validation errors from missing-signature-password flow.\n\nUse HTTP 422 for revoked, invalid, expired, and unverifiable revocation status cases to avoid incorrect UI actions. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent be351a9 commit 952cd8c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/Service/IdentifyMethod/SignatureMethod/Password.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ private function validateCertificateRevocation(array $certificateData): void {
6363
// fail-closed – we cannot confirm the certificate is not revoked.
6464
throw new LibresignException(
6565
$this->identifyService->getL10n()->t('Certificate revocation status could not be verified'),
66-
400
66+
422
6767
);
6868
}
6969

7070
private function validateCertificateExpiration(array $certificateData): void {
7171
if (array_key_exists('validTo_time_t', $certificateData)) {
7272
$validTo = $certificateData['validTo_time_t'];
7373
if (!is_int($validTo)) {
74-
throw new LibresignException($this->identifyService->getL10n()->t('Invalid certificate'), 400);
74+
throw new LibresignException($this->identifyService->getL10n()->t('Invalid certificate'), 422);
7575
}
7676
$now = (new \DateTime())->getTimestamp();
7777
if ($validTo <= $now) {
78-
throw new LibresignException($this->identifyService->getL10n()->t('Certificate has expired'), 400);
78+
throw new LibresignException($this->identifyService->getL10n()->t('Certificate has expired'), 422);
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)