Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iText setEncryption error

I've recently had to upgrade to iText, but I'm having problems getting setEncryption to work. I'm using iText 5.5.6.

document = new Document(PageSize.LETTER, 36, 36, 72, 72);
writer = PdfWriter.getInstance(document, out);
writer.setEncryption(null, OWNER_PASSWORD.getBytes(), writer.AllowPrinting|writer.AllowCopy, PdfWriter.STANDARD_ENCRYPTION_128);

gets me the following error:

java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package

At first I thought I might be using the wrong JAR file for bouncycastle. I was on 1.52, when apparently iText 5.5.0 wants 1.49, but even using older JAR files, I get the same results.

I've tried both bcprov-jdk15on-1.49 and bcprov-ext-jdk15on-1.49, so I'm really not sure what I'm doing wrong at this point.

like image 323
Beacon80 Avatar asked Jul 12 '26 08:07

Beacon80


1 Answers

It turns out I had a second Bouncy Castle library hiding. Thanks mkl.

like image 104
Beacon80 Avatar answered Jul 13 '26 21:07

Beacon80