Thursday, May 31, 2012

How to digitally sign a pdf file using free software in GNU/Linux

I recently needed to sign a pdf document for legal purposes. The other party was willing to accept a digital signature. That does not mean copying an picture onto a pdf document. It's using public key crypto to sign the pdf document. Acrobat can do it, but I use free software, so, after about 30 minutes I figured out how to do it.

  1. I extracted my csail certificate from my browser. In firefox
    • edit->preferences->advanced->encryption->view certificates
    • select the certificate
    • then hit backup
    • save it as a pkcs12 file
    • you'll be asked for a password for the backup. You'll use this later.
  2. I got jsignpdf-1.3.0 and installed it
    • $ unzip JSignPdf-1.3.0.zip
    • $ cd jsignpdf-1.3.0
  3. I ran it: $ java -jar JSignPdf.jar
    • A simple window popped up with some forms to fill in.
      • keystore type: PKCS12
      • keystore file: choose the backup made of the certificate
      • keystore password: the password you used
      • input file: the pdf file to sign
      • output file: I chose another name to avoid overwriting something useful
      • I clicked the checkbox on "visible signature"
      • Went to the "settings" box next to 'visible signature"
      • I chose the page where the signature needed to be placed, and I chose coordinates. I found the coordinates by running gv input.pdf since ghostview shows the coordinates in the upper left corner. For example, I put my signature on page 7 and put signature at coordinates
        • 147
        • 482
        • 369
        • 519
      • I chose Display: "Signature name and decsription"
      • Hit "close"
    • Then "sign it" on the original jpdfsign window.