Skip to content

Commit b215b4b

Browse files
authored
Update netty/remove tcnative+boringssl dependencies (logstash-plugins#126)
This commit updates netty dependency to 4.1.49.final, and additionally removes the dependency on tcnative + boringssl This commit also handles JCE restrictions While it is been the default for Java since JDK 8u161 released in early 2018, old versions of Java may not have the JCE unlimited strength jurisdiction policy installed. This commit handles this case, warning the user that the policy is not installed, and presenting a reduced set of default ciphers for use.
1 parent 5af7ff3 commit b215b4b

File tree

5 files changed

+53
-14
lines changed

5 files changed

+53
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.3.5
2+
- Updated jackson databind and Netty dependencies. Additionally, this release removes the dependency on `tcnative` +
3+
`boringssl`, using JVM supplied ciphers instead. This may result in fewer ciphers being available if the JCE
4+
unlimited strength jurisdiction policy is not installed. (This policy is installed by default on versions of the
5+
JDK from u161 onwards)[#126](https://github.com/logstash-plugins/logstash-input-http/pull/126)
6+
17
## 3.3.4
28
- Refactor: scope (and avoid unused) java imports [#124](https://github.com/logstash-plugins/logstash-input-http/pull/124)
39

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.4
1+
3.3.5

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ dependencies {
2222
testCompile 'org.hamcrest:hamcrest-library:1.3'
2323
testCompile 'org.apache.logging.log4j:log4j-core:2.11.1'
2424

25-
compile 'io.netty:netty-all:4.1.30.Final'
26-
compile 'io.netty:netty-tcnative-boringssl-static:2.0.12.Final'
25+
compile 'io.netty:netty-all:4.1.49.Final'
2726
compile 'org.apache.logging.log4j:log4j-api:2.11.1'
28-
2927
}
3028

3129
test {

lib/logstash/inputs/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
9393
config :tls_max_version, :validate => :number, :default => TLS.max.version
9494

9595
# The list of ciphers suite to use, listed by priorities.
96-
config :cipher_suites, :validate => :array, :default => org.logstash.plugins.inputs.http.util.SslSimpleBuilder::DEFAULT_CIPHERS
96+
config :cipher_suites, :validate => :array, :default => org.logstash.plugins.inputs.http.util.SslSimpleBuilder.getDefaultCiphers
9797

9898
# Apply specific codecs for specific content types.
9999
# The default codec will be applied only after this list is checked

src/main/java/org/logstash/plugins/inputs/http/util/SslSimpleBuilder.java

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.logstash.plugins.inputs.http.util;
22

3-
import io.netty.handler.ssl.OpenSsl;
43
import io.netty.handler.ssl.SslContext;
54
import io.netty.handler.ssl.SslContextBuilder;
65
import org.apache.logging.log4j.LogManager;
@@ -18,6 +17,8 @@
1817
import java.util.ArrayList;
1918
import java.util.Arrays;
2019
import java.util.List;
20+
import javax.crypto.Cipher;
21+
import javax.net.ssl.SSLServerSocketFactory;
2122

2223
public class SslSimpleBuilder implements SslBuilder {
2324

@@ -26,9 +27,8 @@ public class SslSimpleBuilder implements SslBuilder {
2627
/*
2728
Modern Ciphers Compatibility List from
2829
https://wiki.mozilla.org/Security/Server_Side_TLS
29-
This list require the OpenSSl engine for netty.
3030
*/
31-
public final static String[] DEFAULT_CIPHERS = new String[] {
31+
private final static String[] DEFAULT_CIPHERS = new String[] {
3232
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
3333
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
3434
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
@@ -39,25 +39,40 @@ public class SslSimpleBuilder implements SslBuilder {
3939
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
4040
};
4141

42-
private String[] ciphers = DEFAULT_CIPHERS;
42+
private final static String[] DEFAULT_CIPHERS_LIMITED = new String[] {
43+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
44+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
45+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
46+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
47+
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
48+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
49+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
50+
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
51+
};
52+
53+
private String[] ciphers = getDefaultCiphers();
4354
private File sslKeyFile;
4455
private File sslCertificateFile;
4556
private String[] certificateAuthorities;
4657
private String passPhrase;
58+
private String[] supportedCiphers = ((SSLServerSocketFactory)SSLServerSocketFactory
59+
.getDefault()).getSupportedCipherSuites();
4760

4861
public SslSimpleBuilder(String sslCertificateFilePath, String sslKeyFilePath, String pass) throws FileNotFoundException {
4962
sslCertificateFile = new File(sslCertificateFilePath);
5063
sslKeyFile = new File(sslKeyFilePath);
5164
passPhrase = pass;
52-
ciphers = DEFAULT_CIPHERS;
5365
}
5466

5567
public SslSimpleBuilder setCipherSuites(String[] ciphersSuite) throws IllegalArgumentException {
5668
for(String cipher : ciphersSuite) {
57-
if(!OpenSsl.isCipherSuiteAvailable(cipher)) {
69+
if(Arrays.asList(supportedCiphers).contains(cipher)) {
70+
logger.debug("Cipher is supported: {}", cipher);
71+
}else{
72+
if (!isUnlimitedJCEAvailable()) {
73+
logger.warn("JCE Unlimited Strength Jurisdiction Policy not installed");
74+
}
5875
throw new IllegalArgumentException("Cipher `" + cipher + "` is not available");
59-
} else {
60-
logger.debug("Cipher is supported: " + cipher);
6176
}
6277
}
6378

@@ -74,7 +89,7 @@ public SslContext build() throws IOException, NoSuchAlgorithmException, Certific
7489
SslContextBuilder builder = SslContextBuilder.forServer(sslCertificateFile, sslKeyFile, passPhrase);
7590

7691
if(logger.isDebugEnabled()) {
77-
logger.debug("Available ciphers:" + Arrays.toString(OpenSsl.availableOpenSslCipherSuites().toArray()));
92+
logger.debug("Available ciphers: " + Arrays.toString(supportedCiphers));
7893
logger.debug("Ciphers: " + Arrays.toString(ciphers));
7994
}
8095

@@ -116,4 +131,24 @@ private boolean requireClientAuth() {
116131

117132
return false;
118133
}
134+
135+
public static String[] getDefaultCiphers(){
136+
if (isUnlimitedJCEAvailable()){
137+
return DEFAULT_CIPHERS;
138+
} else {
139+
logger.warn("JCE Unlimited Strength Jurisdiction Policy not installed - max key length is 128 bits");
140+
return DEFAULT_CIPHERS_LIMITED;
141+
}
142+
}
143+
144+
145+
public static boolean isUnlimitedJCEAvailable(){
146+
try {
147+
return (Cipher.getMaxAllowedKeyLength("AES") > 128);
148+
} catch (NoSuchAlgorithmException e) {
149+
logger.warn("AES not available", e);
150+
return false;
151+
}
152+
}
153+
119154
}

0 commit comments

Comments
 (0)