JDK/JRE source code with matching JSSE (SSL) source code and matching runnable JDK / JRE?

后端 未结 8 1077
庸人自扰
庸人自扰 2021-02-05 20:30

I have seen Where to find Java 6 JSSE/JCE Source Code? and asked the question myself How to get JRE/JDK with matching source? but I don\'t either of these was specific enough

8条回答
  •  花落未央
    2021-02-05 20:48

    I used the OpenJDK download for Java 6:

    http://download.java.net/openjdk/jdk6/

    To debug the JSSE/SSL code, I used the classes found in the sun.security.ssl and sun.security.ec packages and created a new library. Unfortunately, just having a library with all the source wasn't enough for me. I couldn't figure out how to get my IDE (Netbeans) to step into the JSSE code. Instead, it was calling the JSSE bundled with my JDK.

    As a workaround, I ended up refactoring the ssl and ec packages into a new "Provider". Here's what I did:

    1. Renamed the SunJSSE class to SSLProvider and replaced all references to "SunJSSE" in the code.
    2. Refactored sun.security.ssl and sun.security.ec into 2 new packages: javaxt.ssl and javaxt.ec
    3. Find/Replace all references to the original package names in the code. For example, in the SSLProvider.java class, replace "sun.security.ssl.SSLContextImpl" with "javaxt.ssl.SSLContextImpl".

    Once I had a new security provider, I could reference it explicitly in my code. Example:

      java.security.Provider provider = new javaxt.ssl.SSLProvider();
      java.security.Security.addProvider(provider);
      SSLContext sslc = SSLContext.getInstance("TLS", "SSLProvider");
    

    By explicitly setting the security provider, I can now drop breakpoints and throw out print statements to my heart's content :-)

    If anyone is interested, I have posted a zip archive of the "SSLProvider" source here:

    http://www.javaxt.com/download/?/jsse/SSLProvider.zip

提交回复
热议问题