Skip to content

Commit fec9cf7

Browse files
committed
configure JSSE (OpenJDK) ... on Java 8 we force 1024/2048 DH keys
... unless user wants otherwise (related to #45)
1 parent f432265 commit fec9cf7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • src/main/java/org/jruby/ext/openssl

src/main/java/org/jruby/ext/openssl/SSL.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ public class SSL {
6565
public static final long OP_NETSCAPE_CA_DN_BUG = 0x20000000L;
6666
public static final long OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 0x40000000L;
6767

68+
static { configureJSSE(); }
69+
70+
private static void configureJSSE() {
71+
final String ephemeralDHKeySize = "jdk.tls.ephemeralDHKeySize";
72+
try {
73+
if ( System.getProperty(ephemeralDHKeySize) == null ) {
74+
// The key size is the same as the authentication certificate,
75+
// but must be between 1024 bits and 2048 bits, inclusively.
76+
// However, the SunJCE provider only supports 2048-bit DH keys larger
77+
// than 1024 bits. Consequently, you may use the values 1024 or 2048 only.
78+
System.setProperty(ephemeralDHKeySize, "matched"); // only affects Java 8
79+
}
80+
}
81+
catch (SecurityException ex) {
82+
OpenSSL.debug("setting " + ephemeralDHKeySize + " failed: " + ex);
83+
}
84+
}
85+
6886
public static void createSSL(final Ruby runtime, final RubyModule OpenSSL) {
6987
final RubyModule SSL = OpenSSL.defineModuleUnder("SSL");
7088
final RubyClass OpenSSLError = OpenSSL.getClass("OpenSSLError");

0 commit comments

Comments
 (0)