Skip to content

Commit 34a3066

Browse files
committed
Disable SSlv2ClientHello by default, close AsyncHttpClient#934
1 parent 1f9dea2 commit 34a3066

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ public static class Builder {
605605
private int maxRequestRetry = defaultMaxRequestRetry();
606606
private boolean disableUrlEncodingForBoundRequests = defaultDisableUrlEncodingForBoundRequests();
607607
private int ioThreadMultiplier = defaultIoThreadMultiplier();
608-
private String[] enabledProtocols;
608+
private String[] enabledProtocols = defaultEnabledProtocols();
609609
private String[] enabledCipherSuites;
610610
private Integer sslSessionCacheSize = defaultSslSessionCacheSize();
611611
private Integer sslSessionTimeout = defaultSslSessionTimeout();

api/src/main/java/org/asynchttpclient/channel/SSLEngineFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package org.asynchttpclient.channel;
1515

16+
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
17+
1618
import java.security.GeneralSecurityException;
1719

1820
import javax.net.ssl.SSLContext;
@@ -55,10 +57,10 @@ public SSLEngine newSSLEngine(String peerHost, int peerPort) throws GeneralSecur
5557
}
5658
sslEngine.setUseClientMode(true);
5759

58-
if (config.getEnabledProtocols() != null)
60+
if (isNonEmpty(config.getEnabledProtocols()))
5961
sslEngine.setEnabledProtocols(config.getEnabledProtocols());
6062

61-
if (config.getEnabledCipherSuites() != null)
63+
if (isNonEmpty(config.getEnabledCipherSuites()))
6264
sslEngine.setEnabledCipherSuites(config.getEnabledCipherSuites());
6365

6466
return sslEngine;

api/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public static String defaultUserAgent() {
7070
public static int defaultIoThreadMultiplier() {
7171
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT_CONFIG_ROOT + "ioThreadMultiplier");
7272
}
73+
74+
public static String[] defaultEnabledProtocols() {
75+
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT + "enabledProtocols");
76+
}
7377

7478
public static boolean defaultUseProxySelector() {
7579
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + "useProxySelector");

api/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ public String apply(String key) {
7373
});
7474
}
7575

76+
public String[] getStringArray(String key) {
77+
String s = getString(key);
78+
String[] rawArray = s.split(",");
79+
String[] array = new String[rawArray.length];
80+
for (int i = 0; i < rawArray.length; i++)
81+
array[i] = rawArray[i].trim();
82+
return array;
83+
}
84+
7685
public int getInt(String key) {
7786
return Integer.parseInt(getString(key));
7887
}

api/src/main/resources/ahc-default.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ org.asynchttpclient.maxRedirects=5
1111
org.asynchttpclient.compressionEnforced=false
1212
org.asynchttpclient.userAgent=NING/1.0
1313
org.asynchttpclient.ioThreadMultiplier=2
14+
org.asynchttpclient.enabledProtocols=TLSv1.2, TLSv1.1, TLSv1
1415
org.asynchttpclient.useProxySelector=false
1516
org.asynchttpclient.useProxyProperties=false
1617
org.asynchttpclient.strict302Handling=false

0 commit comments

Comments
 (0)