10

I am trying to debug an issue with bouncy castle 1.47. I can find a debug jar for 'bcprov' but not for {org.bouncycastle:bcpkix-jdk15on:1.47:jar}.

Is there any other place to download bcpkix-jdk15on-1.47.jar with debug information?

or

Is there a tool that can generate line numbers from a jar (containing .class files) without line numbers and also generated sources for the same generated jar?

or

I had been trying to build the jars from source 1 but the build cannot find the test jars I suppose from the errors.

  [javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:5: package junit.framework does not exist
  [javadoc] import junit.framework.Test;
  [javadoc]                       ^
  [javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:6: package junit.framework does not exist
  [javadoc] import junit.framework.TestCase;
  [javadoc]                       ^
  [javadoc] /tickets/bouncycastle/src-cvs/java/crypto/build/artifacts/jdk1.5/bcprov-jdk15on-147/src/org/bouncycastle/jce/provider/test/AllTests.java:7: package junit.framework does not exist
  [javadoc] import junit.framework.TestSuite;

Any help is appreciated.

Rag
  • 1,363
  • 4
  • 19
  • 36

2 Answers2

12

I have managed to generate jar with debug information from bouncy castle source.

in ROOT_SRC/bc-build.properties, set release.debug to true

release.suffix: 147
release.name: 1.47
release.debug: true

The build expects mail (sun implementation) and junit jars to be available in classpath. I have put them on to jdk/jre/lib/ext and the build worked. the artifacts were generated in the ROOT_SRC/build directory.

Rag
  • 1,363
  • 4
  • 19
  • 36
  • I had to add the Gradle Wrapper. And the repo now already contains the dependencies listed above. But otherwise, the experience was the same - easy to build your debug copy. Thanks Rag! – Harri Feb 01 '23 at 14:01
  • Nicely worked. I just had to set debug=true and ``` export JDKPATH=/usr/lib/jvm/java-1.8.0-amazon-corretto bash build1-8+ ``` and got the files in `build/artifacts/jdk1.8/jars` – Daniel Schröter Aug 18 '23 at 13:18
7

Instead of rolling your own build, you could exclude bcprov-jdk15on and explicitly pull in the debug-built bcprov-debug-jdk15on artifact.

Maven config example:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpkix-jdk15on</artifactId>
    <version>${bouncycastle.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-debug-jdk15on</artifactId>
    <version>${bouncycastle.version}</version>
</dependency>

This will allow you to debug bouncycastle stuff.

Kenneth
  • 98
  • 1
  • 2
  • 2
    Does it enable to debug bcpkix-jdk15on as the OP is asking?. – Jaime Hablutzel Dec 12 '20 at 01:23
  • @JaimeHablutzel This depends. My case was that while my app depended on bcpkix, the actual part I needed to debug was from bcprov on which bcpkix depended on. So for me - it helped. I didn't need to swap out bcpkix, only bcprov and I could do my debugging. – Harri Feb 01 '23 at 13:59