Skip to content

Commit

Permalink
fix for verification of unsigned documents
Browse files Browse the repository at this point in the history
  • Loading branch information
fcorneli committed May 20, 2015
1 parent 5605059 commit c121e23
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
9 changes: 8 additions & 1 deletion dssp/dssp.php
Expand Up @@ -412,7 +412,14 @@ public function verify($data, $mimetype = "application/pdf") {
}

$verificationResult = new VerificationResult();
$verificationResult->renewTimeStampBefore = $verifyResponse->OptionalOutputs->any["TimeStampRenewal"]->Before;
if (array_key_exists("TimeStampRenewal", $verifyResponse->OptionalOutputs->any)) {
$verificationResult->renewTimeStampBefore = $verifyResponse->OptionalOutputs->any["TimeStampRenewal"]->Before;
}

if (!property_exists($verifyResponse->OptionalOutputs->any["VerificationReport"], "IndividualReport")) {
$verificationResult->signatureInfos = array();
return $verificationResult;
}

if (is_array($verifyResponse->OptionalOutputs->any["VerificationReport"]->IndividualReport)) {
$verificationResult->signatureInfos = array();
Expand Down
25 changes: 21 additions & 4 deletions verify.php
Expand Up @@ -8,7 +8,7 @@
include_once "dssp/dssp.php";

$dssClient = new DigitalSignatureServiceClient();

$pdf_handle = fopen("document-1.pdf", "r");
$pdfData = fread($pdf_handle, 65536);
fclose($pdf_handle);
Expand All @@ -23,9 +23,24 @@
echo "</tr>";
}
echo "</table>";

$pdf_handle = fopen("document-2.pdf", "r");
$pdfData = fread($pdf_handle, 128*1024);
$pdfData = fread($pdf_handle, 128 * 1024);
fclose($pdf_handle);

$verificationResult = $dssClient->verify($pdfData);
echo "<p>Renew timestamp before: " . $verificationResult->renewTimeStampBefore . "</p>";
echo "<table>";
foreach ($verificationResult->signatureInfos as $signatureInfo) {
echo "<tr>";
echo "<td>" . $signatureInfo->signingTime . "</td>";
echo "<td>" . $signatureInfo->subject . "</td>";
echo "</tr>";
}
echo "</table>";

$pdf_handle = fopen("document.pdf", "r");
$pdfData = fread($pdf_handle, 128 * 1024);
fclose($pdf_handle);

$verificationResult = $dssClient->verify($pdfData);
Expand All @@ -38,6 +53,8 @@
echo "</tr>";
}
echo "</table>";

echo "<p>done</p>";
?>
</body>
</html>
</html>

0 comments on commit c121e23

Please sign in to comment.