I need to insert a digital signature into already existing pdf files, using a rails application server. (Basically, clients upload pdf files and the server signs them with a local certificate)
I’ve been using JSignpdf to insert digital signatures into pdf files, and started probing for gems for ruby…
I’ve found another portable file to do this job on rubypdf site http://soft.rubypdf.com/software/pdf-digital-signe, but cannot find any gem or even example code to do this in ruby.
I’ve looked also at Digital signature verification with OpenSSL, but couldn’t understand how to actually sign an already existing document, with a local certificate file.
I also took a peak at http://code.google.com/p/origami-pdf/ , but this seems a bit harsh for a supposingly “simple” (at least in concept) task.
Any ideas/suggestions?
Thank you
After some research, recurring to the OpenSSL documentation and exploring the Origami solution, i built the code below, and managed to insert a locally generated signature/certificate into a pdf document. Now I just need to figure out how to use this with an external generated certificate (check version 2 below, where i solved it). I’ve opened a new question where you can find some details on a difficulty i had with OpenSSL and DER encoded certificates.
To develop version 2, i also spent some time wondering how to add an annotation – so the signature becomes visible in Adobe reader – without adding a new page to the document. From origami documentation, i found the get_page method, which solved my last problem on this. I’m using Adobe Reader X, for the record.
Hope you find this useful as I will ;-).
VERSION 1 – Generate certificate and key file, and insert them directly into the document
VERSION 2 – Use existing certificates to sign a pdf document