Getting digital signature Error "Error Encountered while BER decoding" using TCPDF

问题描述 投票:0回答:1

我使用 TCPDF 在 PDF 文档上创建数字签名。 我几乎使用这里提到的代码:

http://www.tcpdf.org/examples/example_052.phps

并且在我的服务器 (linux) 上浏览时,我使用与我在服务器上用于 SSL 的相同的 crt 文件。 但是无论文件存在与否,无论是哪个路径,哪个服务器,我总是报同样的错误

我得到错误:

“BER解码时遇到错误”

我的服务器是 Centos 6.3(64bit), Apache/2.2.15 (CentOS) , PHP Version 5.3.3, MySQLi 5.1.67

我的密码是:

$pdf = new TCPDF();
// set document information
$pdf->SetCreator('DejaVuSansCondensed');
$pdf->SetAuthor('Soft1');
$pdf->SetTitle('Soft1 Verified');
$pdf->SetSubject('Soft1 Verified');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set font
$pdf->SetFont('DejaVuSansCondensed', '', 10);

// set certificate file
$certificatePath = 'file://home/tcpdf.crt';

// set additional information
$info = array
(
    'Name' => 'Soft1',
    'Location' => 'Server',
    'Reason' => 'Signing Document',
    'ContactInfo' => 'http://www.soft1.com',
);

// set document signature
$pdf->setSignature($certificatePath, $certificatePath, 'tcpdfdemo', '', 2, $info);

// add a page
$pdf->AddPage();

// set LTR direction for english translation
$pdf->setRTL(true);

// output the HTML content
$pdf->writeHTML($printable, true, 0, true, 0);

// create content for signature (image and/or text)
$pdf->Image('themes/default/images/digital_signature.png', 25, 11, 15, 15, 'PNG');

$pdf->setSignatureAppearance(25, 11, 15, 15);               

if($task == 'pdf'){
    //$GLOBALS['log']->fatal("file_name = " . $file_name);
    //$file_name = "hello.pdf";
    $pdf->Output($file_name, "D");
}

谁能告诉我哪里出了问题? 在网上搜索了这个错误。除了旧的论坛帖子几乎什么都没有。

pdf digital-signature tcpdf
1个回答
0
投票

有同样的问题并通过替换解决了它:

$certificatePath = 'file:///home/tcpdf.crt';

注意路径中多余的'/'

© www.soinside.com 2019 - 2024. All rights reserved.