iText 设置加密错误
iText setEncryption error
我最近不得不升级到 iText,但我在使用 setEncryption 时遇到了问题。我正在使用 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
起初我以为我可能为 bouncycastle 使用了错误的 JAR 文件。我使用的是 1.52,显然 iText 5.5.0 需要 1.49,但即使使用较旧的 JAR 文件,我也会得到相同的结果。
我已经尝试了 bcprov-jdk15on-1.49 和 bcprov-ext-jdk15on-1.49,所以我真的不确定我现在做错了什么。
原来我藏了第二个 Bouncy Castle 库。谢谢mkl.
我最近不得不升级到 iText,但我在使用 setEncryption 时遇到了问题。我正在使用 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
起初我以为我可能为 bouncycastle 使用了错误的 JAR 文件。我使用的是 1.52,显然 iText 5.5.0 需要 1.49,但即使使用较旧的 JAR 文件,我也会得到相同的结果。
我已经尝试了 bcprov-jdk15on-1.49 和 bcprov-ext-jdk15on-1.49,所以我真的不确定我现在做错了什么。
原来我藏了第二个 Bouncy Castle 库。谢谢mkl.