sri_sankl
sri_sankl

Reputation: 243

How to add digital signature to pdf in Ruby?

I am generating pdf using wicked_pdf and I am also using prawntable for pdfs which needs to be password protected. Since wicked pdf doesnt supports password protected pdf generation.

Is there any way to add a digital signature which is in .pfx format to pdf.?

Upvotes: 2

Views: 3475

Answers (2)

Jaime Hablutzel
Jaime Hablutzel

Reputation: 6343

The Origami library has a very basic support for PDF digital signatures and there is sample code for this at https://github.com/gdelugre/origami/blob/master/examples/signature/signature.rb.

Upvotes: 1

Larry K
Larry K

Reputation: 49104

Passwording pdf files vs digitally signing them

Passwording a pdf file encrypts the file. You will need to find a pdf library/toolkit to do that for you. If you can't find one with a ruby API, then you can call it as a command from ruby. The latter is not as elegant but works fine. (Be sure to catch and handle errors.)

Digitally signing a pdf is completely different than encryption. The result of signing is a pdf with one or more digital signatures. You use either a library to sign a file locally or, for a more dependable system, sign the file via a dedicated appliance that also holds the signer's private key and certificate.

Unlike password protection/encryption, anyone who receives a digitally signed pdf file can read the file's content. The digital signatures provide the relying party (the recipient) with assurances about:

  • the identity of the person who signed the file
  • the integrity of the file (confirming that it wasn't changed since signing)
  • the non-reputability of the file (confirming that the signer can't claim that they hadn't signed the file)

An important issue is that having a signer's private key on the file system of a regular computer/server is not secure enough to provide any guarantee against repudiation by the signer--she could truthfully say that there is no way to assure that her "signature" was not forged by un-authorized use of the pfx file.

Upvotes: 1

Related Questions