Jump to content
  • BouncyCastle upgrade problem 1.62 to 1.64

    Assigned User lucianc
    CategoryBug report
    Component: 14539
    StatusFeedback Requested

    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.(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)

    User Feedback

    Recommended Comments

    Changed Status from New to Feedback Requested

    Changed Assigned User from - to @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
    Link to comment
    Share on other sites

    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...





    Link to comment
    Share on other sites

    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?





    Link to comment
    Share on other sites

    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)


    ArrayList vs = (ArrayList)values.get(id);

    if (vs == null) {

    vs = new ArrayList();

    values.put(id, vs);


    // TIBCO Software #6 : Part 19 - START


    // TIBCO Software #6 : Part 19 - END






    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...