Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting private key in C:\xampp\htdocs\this\tcpdf\tcpdf.php on line 8366

I am using TCPDF to sign PDF, but when running the example 52 I got this error:

Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting 
private key in C:\xampp\htdocs\this\tcpdf\tcpdf.php on line 8366

Could you please tell me or guide me where is the problem. I am just running the example without changing anything. I am using xampp.

like image 607
lionc Avatar asked Aug 17 '11 17:08

lionc


2 Answers

The problem is with the location from where it tries to access the private key. Instead of '' like in their example use 'file://'.( dirname(FILE)).'./path/to/file'. This worked for me.

like image 59
NamingException Avatar answered Jan 02 '23 07:01

NamingException


I solved it by using:

$certificate = 'file://'.realpath('../tcpdf.crt');

When you create your own certificate use this:

/*
NOTES:
 - To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
 - To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12
 - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes
*/
like image 39
NetworkSys Co. Ltd Avatar answered Jan 02 '23 07:01

NetworkSys Co. Ltd