23

I have already acquired a S/MIME certificate (a .p12 file) issued by an authority. Using it in Writer, I can digitally sign documents by following this procedure : How do I make a digital certificate available to LibreOffice Writer for digital signatures?

Can I do the same for PDF files? If yes, what method do you suggest me? I would prefer a solution that relies on Free Software.

13

I found that you can use gpg to sign a PDF in a way that it still opens up in a viewer.

gpg --clearsign --output=signed.pdf input.pdf

Above would yield .asc file which is basically concatenation of input||signature but file extension is forced into .pdf making it to open in viewer, produce thumbnails, etc.

enter image description here

You can verify signature using gpg again.

$ gpg --verify signed.pdf 
gpg: Podpisano nie, 12 kwi 2015, 19:07:15 CEST z użyciem RSA kluczem
gpg: Poprawny podpis od "Arkadiusz Bulski <arek.bulski@gmail.com>"

Be warned that some pdfs dont work well with signing this way, such as optimised pdfs. You should check the results yourself.

  • 1
    Do PDF readers give any indication that this is a PGP-signed PDF? – Mendhak Jun 1 '17 at 19:20
  • No, PDF is viewed despite the attached signature. – ArekBulski Jun 2 '17 at 13:51
  • 1
    Perhaps GPG header will be ignored by some software, but Adobe Acrobat Reader and Foxit Reader don't like it and consider such PDF broken. So yes, mind interoperability problem. – dma_k Oct 6 '17 at 10:02
  • Interesting, but the question was about S/MIME certificates. – Andy Oct 25 '17 at 18:51
  • How to view this non-detached-signature embedded PDF at all? – SYK Oct 1 '18 at 22:27
7

You can sign PDF files with gpg/seahorse.

Learn more: https://help.ubuntu.com/community/GnuPrivacyGuardHowto

You can for instance use OpenSignPDF, that can be download here: http://opensignature.sourceforge.net/english.php

I hope this answers your question.

  • Thank you Subv3rsion! Alternatively, I also found some proprietary programs in the Ubuntu Software Center. But I am not going to make advertisement here. – Agmenor Jun 6 '12 at 17:58
  • 3
    Ok, but please, can you tell me what programs did you found? – Octávio Filipe Gonçalves Jun 6 '12 at 18:02
  • 1
    Note that GPG and Seahorse might not like the S/MIME format that PDF(s) sometimes require in business environments. – Thomas Ward Jun 6 '12 at 18:15
  • 2
    Some times, some people really need to sign with a .p12. This doesn't answer the question. – jgomo3 Feb 26 '14 at 0:12
7

If you have the certificate available in Writer and if using its Export to PDF function, you can also digitally sign the resulting PDF from the last tab of the dialog right before the export.

AFAICT, Acrobat Reader for Android says the document is protected, FWIW.

Update '17: Since last December you can sign PDF files with LibreOffice by going File → Digital signatures → Sign exiting PDF.

That will open Draw which is capable of signing the PDF.

  • I notice it sometimes fails to find the font and then it distorts the entire document, pushing text off the page – Jonathan Oct 14 '18 at 5:31
7

Your only option is Portable Signer. Download it and run the jar. It requires a private key in a p12 file though (not compatible with SmartCard).

You might expect Ubuntu document signing tools like qdigidoc or gpg would do, but no, they don't play with PDF signatures.

You might then expect Ubuntu PDF manipulation tools like qpdf, which provides encryption, or pdftk, which provides watermarking, to provide signing features too, but, no, they don't.

The total list of opensource tools available for your purpose is: http://wiki.cacert.org/PdfSigning

Unfortunately, none of the tools is currently maintained and none can be found in Ubuntu packages. Portable Signer is the most well maintained of all.

  • Portable Signer hasn't been updated since 2014 - this is the most well maintained among all.
  • jSignPdf hasn't been updated since 2013.
  • jPdfSign hasn't been updated since 2006.
  • CACert's PdfSigner uses outdated iText tool.
  • OpenSignature hasn't been updated since 2008.
  • Footprint's link is broken.
  • jPDFSecure (commercial) – updated in 2017 but it is a Java library not a user tool.
2

Master PDF Editor has a free version that will sign .p12 files.

However the free version leaves an ugly watermark. Interestingly enough, this can be removed within the program itself or with another PDF editor (ex. LibreOffice Draw).

1

PDF Studio 7 Pro, available in the Software Center, features digital signing of PDFs. As of when I am writing it costs only 125 $.

According to the official website, it is indeed S/MIME signing.

-1

I ended up doing following

1) Installed Virtual Box 
2) Then installed virtual box extension pack (For usb token)
3) Download windows 10 iso available for free from MS website.
4) Boot into windows downloaded Adobe reader and signed the document.

Not the native solution but it gets the work done.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.