[#12341] - BouncyCastle upgrade problem 1.62 to 1.64

Category:
Bug report
Priority:
Normal
Status:
Feedback Requested
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

Using PdfStamper to digitally sign pdf works fine with BouncyCastle 1.62. Upgrading BC from 1.62 to 1.64 will cause an exception:

java.lang.ClassCastException: class org.bouncycastle.asn1.ASN1UTCTime cannot be cast to class org.bouncycastle.asn1.ASN1Set (org.bouncycastle.asn1.ASN1UTCTime and org.bouncycastle.asn1.ASN1Set are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @554188ac)
at com.lowagie.text.pdf.PdfPKCS7$X509Name.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfPKCS7.getSubjectFields(Unknown Source)
at com.lowagie.text.pdf.PdfSigGenericPKCS.setSignInfo(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfStamper.close(Unknown Source)

v6.10
jasper library
lacimol's picture
Joined: Nov 14 2013 - 2:07am
Last seen: 5 days 12 hours ago

4 Comments:

#1
  • Status:New» Feedback Requested
  • Assigned:nobody» teodord

Hi,

Can you tell us how are you using PdfStamper? Do you have a program that processes an already generated PDF file?

Thanks,
Teodor

#2

Hi Teodor,

I'm using PdfStamper for a generated pdf stream:

// jasperPrint created, doing export
final File tempFile = File.createTempFile("report-", ".tmp");
final FileOutputStream outputStream = new FileOutputStream(tempFile);
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);

// other method
FileInputStream inputStream = new FileInputStream(tempFile);
final PdfReader reader = new PdfReader(inputStream);
final FileOutputStream output = new FileOutputStream(tempFile);
final PdfStamper stp = PdfStamper.createSignature(reader, output, '\0');
// set PdfSignatureAppearance...
stp.close();

Cheers,
Laci

#3

I don't think this is related to JasperReports, is it? You are using iText to modify a PDF that has already been generated, so there is nothing we can do about it in JRL.
What exactly should we fix here?

Thanks,
Teodor

#4

I'm using iText via itext-2.1.7.js7.jar which is modified by you. I think that PdfPKCS7 class X509Name method's iteration should modify to handle not only ASN1Sequence but ASN1UTCTime too (as both are ASN1Primitive).

public X509Name(ASN1Sequence seq) {
Enumeration e = seq.getObjects();

while (e.hasMoreElements()) {
ASN1Set set = (ASN1Set)e.nextElement();

for (int i = 0; i < set.size(); i++) {
ASN1Sequence s = (ASN1Sequence)set.getObjectAt(i);
String id = (String)DefaultSymbols.get(s.getObjectAt(0));
if (id == null)
continue;
ArrayList vs = (ArrayList)values.get(id);
if (vs == null) {
vs = new ArrayList();
values.put(id, vs);
}
// TIBCO Software #6 : Part 19 - START
vs.add(((ASN1String)s.getObjectAt(1)).getString());
// TIBCO Software #6 : Part 19 - END
}
}
}

Feedback
randomness