Sunday, March 4, 2018

Laravel 5.6 and TCPDF Public Key Encryption - development

Laravel 5.6 and TCPDF Public Key Encryption

I am new to PKI and was hoping someone could help me with my situation. I am currently using Laravel 5.6 to develop my site and I am using the elibyy/tcpdf-laravel package for creating PDF’s. Currently, when my users create the PDF it is encrypted via AES 256 and password protected but I would like to add public key encryption.

Here’s is the process, a contract is created via HTML, the user signs the contract, once signed a checkbox appears and a finish button. They check the box and click finish. The webpage is then converted to a PDF and stored on AWS S3.

The following is in the documentation for TCPDF about Public Key Encryption:

 Possible encryption modes are:
 0 = RSA 40 bit
 1 = RSA 128 bit
 2 = AES 128 bit
 3 = AES 256 bit



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

*/

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

// Example with public-key
// To open the document you need to install the private key (tcpdf.p12) on the Acrobat Reader. The password is: 1234
//$pdf->SetProtection($permissions=array('print', 'copy'), $user_pass='', $owner_pass=null, $mode=1, $pubkeys=array(array('c' => 'file://../config/cert/tcpdf.crt', 'p' => array('print'))));

// *********************************************************

Question One: Where do I store the public and private keys? In my Laravel App? On AWS S3?

Question Two: Do I need to generate a public key for each contract?

Question Three: It says to open a document you have to install the private key on Acrobat Reader, I assume this is something the user would have to do in order to open the PDF?

I was hoping there was a tutorial on this, but I can’t seem to find one. Any help is greatly appreciated. Thank you!



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-5-6-and-tcpdf-public-key-encryption/
via Lzo Media

No comments:

Post a Comment