Rodniko
Rodniko

Reputation: 5124

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

I use TCPDF to create digital signature on a PDF document. I use almost the exact code mentioned here:

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

and I use the same crt file that I use for the SSL on my server when browsing to on my server (linux). But no matter if the file exists or not, no matter which path it is or which server, I always get the same error

I get the error:

"Error Encountered while BER decoding"

My server is Centos 6.3(64bit), Apache/2.2.15 (CentOS) , PHP Version 5.3.3, MySQLi 5.1.67

My code is:

$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");
}

Can anyone tell me what is wrong? Searched the web for this error. Almost nothing except old forum posts.

Upvotes: 0

Views: 10390

Answers (1)

Joaquin Segui
Joaquin Segui

Reputation: 1

Had the same issue and solved it by replacing:

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

Note the extra '/' in the path

Upvotes: 0

Related Questions