class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package

StackOverflow https://stackoverflow.com/questions/23396539

  •  13-07-2023
  •  | 
  •  

Question

I am trying to call the following line...

PdfCopy copy = null;
...
copy.setEncryption(password.getBytes(), null, PdfWriter.ALLOW_PRINTING | PdfWriter.ALLOW_COPY, PdfWriter.ENCRYPTION_AES_128)

I get

java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package

This seems to be related to Grails and previous versions of bouncy castle so I tried adding the following to my pom...

    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>rendering</artifactId>
        <version>0.4.4</version>
        <scope>compile</scope>
        <type>zip</type>
        <exclusions>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcmail-jdk14</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcprov-jdk14</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- Needed for rendering plugin -->
    <dependency>
        <groupId>org.xhtmlrenderer</groupId>
        <artifactId>core-renderer</artifactId>
        <version>R8</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcmail-jdk14</artifactId>
            </exclusion>
            <exclusion>
                <groupId>bouncycastle</groupId>
                <artifactId>bcprov-jdk14</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    ...
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.47</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcmail-jdk15on</artifactId>
        <version>1.47</version>
    </dependency>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bctsp-jdk15</artifactId>
        <version>1.46</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

But no dice.... I am using Grails 2.3.7 Anyone have any advice?

Also when I run mvn dependency:tree -Dverbose I don't see any other references.

Was it helpful?

Solution

Problem was related to the grails-doc plugin. I found this by running grails dependency-report this showed an old iText dependency in grails-doc.

Excluding this in the BuildConfig worked fine.

Basically this...

How to exclude grails global dependency

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top