testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
8.03k stars 1.65k forks source link

Using BouncyCastle results in 'myJar.jar has unsigned entries' #1567

Closed DianaMeissen closed 5 years ago

DianaMeissen commented 5 years ago

Hi everyone! Can you please help me with my issue? I add bouncyCastle as a dependency into pom.xml file and have an exception every time when trying to start my .jar file

Exception in thread "main" java.lang.SecurityException: JCE cannot authenticate the provider BC
        at javax.crypto.Cipher.getInstance(Cipher.java:656)
        at com.bmw.cxml.CryptoUtils.aesDecrypt(CryptoUtils.java:54)
        at com.bmw.cxml.CryptoUtils.aesDecryptCBC(CryptoUtils.java:19)
        at com.bmw.cxml.ServiceDpParser.patchData(ServiceDpParser.java:37)
        at com.bmw.SACXMLPatcher.patchFiles(SACXMLPatcher.java:36)
        at com.bmw.App.main(App.java:16)
Caused by: java.util.jar.JarException: file:/C:/Users/Desktop/XMLChangerTool/target/XMLChangerTool-1.0-SNAPSHOT.jar has unsigned entries - com/bmw/App.class
        at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:502)
        at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:363)
        at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
        at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:164)
        at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:190)
        at javax.crypto.Cipher.getInstance(Cipher.java:652)

here is a pom file

<dependencies>
        <dependency>
            <groupId>bouncycastle</groupId>
            <artifactId>bcprov-jdk15</artifactId>
            <version>140</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
    </dependencies>

  <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.bmw.App</mainClass>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <index>true</index>
                        <manifest>
                            <mainClass>com.bmw.App</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Already was trying solutions from this issue like

Security.removeProvider("BC")
Security.addProvider(new BouncyCastleProvider())

and security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider but it doesn't help. Already have no idea what to do. Please help

bsideup commented 5 years ago

Hi @DianaMeissen,

BouncyCastle is not part of Testcontainers project. Please report it to them.