问题描述
我最近不得不升级到iText,但是我在设置setEncryption时遇到了问题。我正在使用iText 5.5.6。
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);
给我带来以下错误:
java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package
起初我以为我可能会使用错误的JAR文件进行bouncycastle。我在1.52,显然iText 5.5.0想要1.49,但即使使用较旧的JAR文件,我也得到相同的结果。
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.
我试过两个bcprov-jdk15on -1.49和bcprov-ext-jdk15on-1.49,所以我真的不确定我在这一点上做错了什么。
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.
推荐答案
事实证明我有一个隐藏的第二个Bouncy Castle图书馆。谢谢mkl。
It turns out I had a second Bouncy Castle library hiding. Thanks mkl.
这篇关于iText setEncryption错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!