|
8 | 8 |
|
9 | 9 | namespace OCA\Libresign\Service\IdentifyMethod\SignatureMethod; |
10 | 10 |
|
| 11 | +use OCA\Libresign\AppInfo\Application; |
11 | 12 | use OCA\Libresign\Enum\CrlValidationStatus; |
12 | 13 | use OCA\Libresign\Exception\InvalidPasswordException; |
13 | 14 | use OCA\Libresign\Exception\LibresignException; |
@@ -59,12 +60,24 @@ private function validateCertificateRevocation(array $certificateData): void { |
59 | 60 | if ($status === CrlValidationStatus::DISABLED) { |
60 | 61 | return; |
61 | 62 | } |
62 | | - // Any other status (urls_inaccessible, validation_failed, validation_error, etc.): |
63 | | - // fail-closed – we cannot confirm the certificate is not revoked. |
64 | | - throw new LibresignException( |
65 | | - $this->identifyService->getL10n()->t('Certificate revocation status could not be verified'), |
66 | | - 422 |
67 | | - ); |
| 63 | + // MISSING is set before the CRL checker runs (no CDP extension at all), so |
| 64 | + // the toggle is not consulted by the checker. Check it explicitly here. |
| 65 | + if ($status === CrlValidationStatus::MISSING |
| 66 | + && !$this->identifyService->getAppConfig()->getValueBool(Application::APP_ID, 'crl_external_validation_enabled', true)) { |
| 67 | + return; |
| 68 | + } |
| 69 | + throw new LibresignException($this->getRevocationErrorMessage($status), 422); |
| 70 | + } |
| 71 | + |
| 72 | + private function getRevocationErrorMessage(mixed $status): string { |
| 73 | + return match ($status) { |
| 74 | + CrlValidationStatus::URLS_INACCESSIBLE => $this->identifyService->getL10n()->t('Cannot reach the certificate revocation service. Signing is blocked.'), |
| 75 | + CrlValidationStatus::VALIDATION_ERROR => $this->identifyService->getL10n()->t('An error occurred during certificate validation. Signing is blocked.'), |
| 76 | + CrlValidationStatus::VALIDATION_FAILED => $this->identifyService->getL10n()->t('Certificate validation failed. Signing is blocked. Contact your administrator if needed.'), |
| 77 | + CrlValidationStatus::NO_URLS => $this->identifyService->getL10n()->t('This certificate has no revocation URLs. Signing is blocked. Contact your administrator.'), |
| 78 | + CrlValidationStatus::MISSING => $this->identifyService->getL10n()->t('This certificate has no revocation information. Signing is blocked. Contact your administrator.'), |
| 79 | + default => $this->identifyService->getL10n()->t('Certificate validation could not be completed. Signing is blocked.'), |
| 80 | + }; |
68 | 81 | } |
69 | 82 |
|
70 | 83 | private function validateCertificateExpiration(array $certificateData): void { |
|
0 commit comments