browsermob-proxy icon indicating copy to clipboard operation
browsermob-proxy copied to clipboard

NoClassDefFoundError when using FIPS enabled BouncyCastle

Open brailsmt opened this issue 1 year ago • 0 comments

This error occurs when using FIPS enabled BouncyCastle libraries.

java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
        at net.lightbody.bmp.mitm.tools.DefaultSecurityProviderTool.<init>(DefaultSecurityProviderTool.java:34)
        at net.lightbody.bmp.mitm.util.TrustUtil.<clinit>(TrustUtil.java:56)
        at net.lightbody.bmp.mitm.TrustSource.javaTrustSource(TrustSource.java:103)
        at net.lightbody.bmp.mitm.TrustSource.<clinit>(TrustSource.java:39)
        at net.lightbody.bmp.BrowserMobProxyServer.<init>(BrowserMobProxyServer.java:225)

Snippet from pom.xml:

            <dependency>
                <groupId>net.lightbody.bmp</groupId>
                <artifactId>browsermob-core</artifactId>
                <version>2.1.5</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.bouncycastle</groupId>
                        <artifactId>bcprov-jdk15to18</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.bouncycastle</groupId>
                        <artifactId>bcpkix-jdk15to18</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.bouncycastle</groupId>
                        <artifactId>bcprov-jdk15on</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.bouncycastle</groupId>
                        <artifactId>bcpkix-jdk15on</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bc-fips</artifactId>
                <version>1.0.2.4</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-fips</artifactId>
                <version>1.0.7</version>
            </dependency>

There is a hardcoded reference to the non-FIPS BouncyCastleProvider here. This should be using java.security configuration for the JVM, as described in the BouncyCastle doc here.

brailsmt avatar May 21 '24 18:05 brailsmt