简体   繁体   English

iText setEncryption错误

[英]iText setEncryption error

I've recently had to upgrade to iText, but I'm having problems getting setEncryption to work. 我最近不得不升级到iText,但是我在设置setEncryption时遇到了问题。 I'm using iText 5.5.6. 我正在使用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. 起初我以为我可能会使用错误的JAR文件进行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. 我在1.52,显然iText 5.5.0想要1.49,但即使使用较旧的JAR文件,我也得到相同的结果。

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. 我已经尝试了bcprov-jdk15on-1.49和bcprov-ext-jdk15on-1.49,所以我真的不确定我在这一点上做错了什么。

It turns out I had a second Bouncy Castle library hiding. 事实证明我有一个隐藏的第二个Bouncy Castle图书馆。 Thanks mkl. 谢谢mkl。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM