TCPDF openssl error creating PKCS7 structure warning

1

I am trying to generate a signed PDF using the TCPDF library

My code is as follows:

App::import('Vendor','mtcpdf');

$pdf = new MTCPDF('L');

$pdf->SetProtection(array('copy'), '', null, 0, null);

$pdf->SetMargins(0, 0, 0, true);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->SetAutoPageBreak(false, 0);

$pdf->AddPage('L');
$pdf->Image($imagen, -7, 1, 310, 210, '', '', '', false, 300, '', false, false, 0);

if(!empty($imagentrasera)){
    $pdf->AddPage('L');
    $pdf->Image($imagentrasera, -7, 1, 310, 210, '', '', '', false, 300, '', false, false, 0);
}



if(!empty($certificado_digital)){

    $info = array(
    'Name' => __('Certificado PDF',true),
    'Location' => '',
    'Reason' => '',
    'ContactInfo' => '',
    );

    $certificado_crt = 'file://'.$_SERVER['DOCUMENT_ROOT'].Configure::read('directorioinstalacion').'app/webroot/Documentos/certificados/certificado.cer';
    $certificado_key = 'file://'.$_SERVER['DOCUMENT_ROOT'].Configure::read('directorioinstalacion').'app/webroot/Documentos/certificados/key.key';
    $pdf->setSignature($certificado_crt,$certificado_key, '', '', 1, $info);
}


echo $pdf->Output(__('Certificado',true).'.pdf', 'D');

I generated the "certificate.cer" using the following command and based on a p12 of the mint and bell:

openssl pkcs12 -in certificate.p12 -out certificado.cer -nodes

And the file "key.key" I generate it taking the zone of private key of file p12 and keeping it as .key.

The following error occurs on this line:

openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED);


Warning (2): openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error creating PKCS7 structure! [CORE\vendors\tcpdf\tcpdf.php, line 7594]

I use PHP 5.6.2 and the routes to the certificates are correct because I echo get_file_contents and display it correctly.

I've been looking everywhere and nothing, I'd appreciate some help.

Greetings !!

    
asked by Luis Cabrero 09.08.2017 в 13:30
source

0 answers