From 9d7f7dae12557b955d0326c5a02ac8d6004f1c24 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 13 Jan 2025 17:05:32 -0300 Subject: [PATCH] chore: display signature issue when haven't proppler Signed-off-by: Vitor Mattos --- lib/Handler/Pkcs12Handler.php | 1 + lib/Service/FileService.php | 22 ++++++++++++++++------ src/views/Validation.vue | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Handler/Pkcs12Handler.php b/lib/Handler/Pkcs12Handler.php index cec07c4c1..a1fd7491c 100644 --- a/lib/Handler/Pkcs12Handler.php +++ b/lib/Handler/Pkcs12Handler.php @@ -156,6 +156,7 @@ public function getCertificateChain($resource): array { $certificates[$signerCounter] = $fromFallback; } if (!$signature) { + $certificates[$signerCounter]['chain'][0]['signature_validation'] = $this->getReadableSigState('Digest Mismatch.'); $signerCounter++; continue; } diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 1f81e2b60..5b8796cfd 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -424,24 +424,34 @@ private function loadLibreSignSigners(): void { private function loadSignersFromCertData(): void { $this->loadCertDataFromLibreSignFile(); foreach ($this->certData as $index => $signer) { - $this->fileData->signers[$index]['subject'] = $signer['chain'][0]['name']; - $this->fileData->signers[$index]['displayName'] = $signer['chain'][0]['subject']['CN']; + if (!empty($signer['chain'][0]['name'])) { + $this->fileData->signers[$index]['subject'] = $signer['chain'][0]['name']; + } + if (!empty($signer['chain'][0]['subject']['CN'])) { + $this->fileData->signers[$index]['displayName'] = $signer['chain'][0]['subject']['CN']; + } if (!empty($signer['chain'][0]['validFrom_time_t'])) { $this->fileData->signers[$index]['valid_from'] = $signer['chain'][0]['validFrom_time_t']; } if (!empty($signer['chain'][0]['validTo_time_t'])) { $this->fileData->signers[$index]['valid_to'] = $signer['chain'][0]['validTo_time_t']; } - $this->fileData->signers[$index]['signed'] = $signer['signingTime']->format('Y-m-d H:i:s'); + if (!empty($signer['signingTime'])) { + $this->fileData->signers[$index]['signed'] = $signer['signingTime']->format('Y-m-d H:i:s'); + } $this->fileData->signers[$index]['signature_validation'] = $signer['chain'][0]['signature_validation']; if (!empty($signer['chain'][0]['certificate_validation'])) { $this->fileData->signers[$index]['certificate_validation'] = $signer['chain'][0]['certificate_validation']; } - $this->fileData->signers[$index]['hash_algorithm'] = $signer['chain'][0]['signatureTypeSN']; + if (!empty($signer['chain'][0]['signatureTypeSN'])) { + $this->fileData->signers[$index]['hash_algorithm'] = $signer['chain'][0]['signatureTypeSN']; + } if (!empty($signer['chain'][0]['subject']['UID'])) { $this->fileData->signers[$index]['uid'] = $signer['chain'][0]['subject']['UID']; - } elseif (preg_match('/^(?.*):(?.*), /', $signer['chain'][0]['subject']['CN'], $matches)) { - $signatureToShow['uid'] = $matches['key'] . ':' . $matches['value']; + } elseif (!empty($signer['chain'][0]['subject']['CN'])) { + if (preg_match('/^(?.*):(?.*), /', $signer['chain'][0]['subject']['CN'], $matches)) { + $signatureToShow['uid'] = $matches['key'] . ':' . $matches['value']; + } } for ($i = 1; $i < count($signer['chain']); $i++) { $this->fileData->signers[$index]['chain'][] = [ diff --git a/src/views/Validation.vue b/src/views/Validation.vue index 8d4ebbf94..b9e818abd 100644 --- a/src/views/Validation.vue +++ b/src/views/Validation.vue @@ -518,7 +518,7 @@ export default { return signer.email } - return 'None' + return signer.signature_validation.label }, getIconValidityPath(signer) { if (signer.is_valid) {