Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sign PDF with a x.509 signature/certificate

tl;dr: I'm looking for a CLI tool that can be fed with a x.509 file and an input PDF and out comes a signed PDF. Best scenario for NodeJS

Hi there. I'm getting a little bit frustrated. I'm looking for a tool which can sign PDF files using the command line. I do use an online service called handy-signatur.at (A service from www.a-trust.at) that generates a x.509 certificate.

I found a page that mentions several tools but it seems that all of them are out of date.

I tried PortableSigner in particular, but that needs Java 6 and I couldn't get it to work on Ubuntu (Server and Desktop edition) 17.04.

/edit: I can't get PortableSigner to work because Java 6 and 7 is no longer available and probably not even safe to use.

Is there any commandline tool out there to sign PDFs?

Thank you guys so much!

like image 781
lumio Avatar asked Jun 25 '17 19:06

lumio


People also ask

How do I Sign a PDF with signing certificates?

Place the image in a document by itself, and convert the document to PDF. Right-click the signature field, and select Sign Document or Certify With Visible Signature.

How do I add a certified digital signature to Adobe PDF?

Just click Fill and sign in the upper right hand corner (or in older versions of Adobe, choose Advanced > Sign & Certify and then select Approval), then click place signature, and place your signature anywhere in the document.


1 Answers

Seems PortableSigner do the work. enter image description here

If you are worried about Java 7 support. Try it with Java 8, probably the digital signature functions still work because nothing important has changed between 7&8

Alternatively, implementing a signature program with Java using libraries like PDFBox or itext is relatively easy. Here you have a full example with pdfbox. Note that it has a main

https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateSignature.java

usage:

java org.apache.pdfbox.examples.signature.CreateSignature 
     <pkcs12_keystore> <password> <pdf_to_sign>
like image 171
pedrofb Avatar answered Oct 19 '22 15:10

pedrofb