iText setEncryption error

一曲冷凌霜 提交于 2020-01-14 14:40:13

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/31929926/itext-setencryption-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!