You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Jeremy Villalobos <je...@gmail.com> on 2013/07/07 04:13:42 UTC

Encrypt Pdf using a X.509 certificate

I googled for a tutorial on using a x.509 certificate to encrypt a pdf. But
I did not find any good source.  What is the benefit of using an X.509
certificate version using owner/user passwords ?

I used a self-signed certificate created with openssl.  I got this error:

Encrypt failed with the following exception:
org.apache.pdfbox.exceptions.COSVisitorException: 1.2.840.113549.3.2
KeyGenerator not available
        at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1347)
        at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1157)
        at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1138)
        at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:189)
        at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
        at org.apache.pdfbox.PDFBox.main(PDFBox.java:40)
org.apache.pdfbox.exceptions.CryptographyException: 1.2.840.113549.3.2
KeyGenerator not available
        at
org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler.prepareDocumentForEncryption(PublicKeySecurityHandler.java:364)
        at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1338)
        at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1157)
        at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1138)
        at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:189)
        at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
        at org.apache.pdfbox.PDFBox.main(PDFBox.java:40)

Am I missing a dependency (bouncy castle perhaps ) or am I using the wrong
certificate ?

Thanks

-- 
Jeremy Villalobos
Practical Android Apps
http://www.practicalandroidapps.com/
<http://www.youtube.com/user/PdfToSpeech>
<https://plus.google.com/u/0/b/109848961267144267628/109848961267144267628/posts>