Good morning. My question is how can I digitally sign a pdf file (or what libraries should I use). I am working under the php symfony2 framework. Thank you in advance.
Good morning. My question is how can I digitally sign a pdf file (or what libraries should I use). I am working under the php symfony2 framework. Thank you in advance.
You have the appropriate extension in PHP itself. You can check the official manual section for more details: link
As an example, I'll make a short and paste of one of the examples I've seen in the manual itself and explain how to sign a file (in this case it's a txt but it could be a pdf or a png or any other ).
<?php
// el mensaje que quiere firmar, por lo que el destinatario puede estar serguro de fue usted
// el que lo envió
$data = <<<EOD
Tiene mi autorización para emplear $10,000 en gastos de comida.
El Presidente
EOD;
// guardar el mensaje en un archivo
$fp = fopen("mensaje.txt", "w");
fwrite($fp, $data);
fclose($fp);
// encriptarlo
if (openssl_pkcs7_sign("mensaje.txt", "firmado.txt", "micert.pem",
array("file://micert.pem", "mi_frase_de_contraseña"),
array("Para" => "[email protected]", // sintaxis asociativa
"DE: C.G. <[email protected]>", // sintaxis indexada
"Tema" => "Confidencial")
)) {
// mensaje firmado - ¡envíelo!
exec(ini_get("ruta_correo") . " < firmado.txt");
}
?>
When using Symfony you should use the logic inside the Controller that manages the signature of the files.
If you are looking for a bundle that encapsulates this functionality (I do not see much sense) I have found one in packagist, but it does not seem very used or updated: link