دنبال کننده ها

۱۳۹۶ مرداد ۱۳, جمعه

php - TCPDF openssl error creating PKCS7 structure warning

[ad_1]



Ive been 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');


My "certificado.cer" file was generated using the OpenSSL library. I used the following command:



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


And my "key.key" file was generated opening the original .p12 certificate and cutting the Key zone and saving it as the key.key file.



Then the code fais here:



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


It displays this:



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


Im using 5.6.25 php version, WAMP local server, and I just cant understand how to solve this, I've been searching on google for a while and found nothing about this.



Any help would be much appreciated!!




[ad_2]

لینک منبع