Skip to content

Commit ba148e0

Browse files
committed
Update default enabled cipher suites, close AsyncHttpClient#1258
1 parent 7255824 commit ba148e0

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2016 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the Apache License Version 2.0 is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
13+
*/
14+
package io.netty.handler.ssl;
15+
16+
import java.util.Set;
17+
18+
public final class NettySslPackageAccessor {
19+
20+
private NettySslPackageAccessor() {
21+
}
22+
23+
public static Set<String> jdkSupportedCipherSuites() {
24+
return JdkSslContext.SUPPORTED_CIPHERS;
25+
}
26+
}

client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public static class Builder {
623623
private boolean acceptAnyCertificate = defaultAcceptAnyCertificate();
624624
private int handshakeTimeout = defaultHandshakeTimeout();
625625
private String[] enabledProtocols = defaultEnabledProtocols();
626-
private String[] enabledCipherSuites;
626+
private String[] enabledCipherSuites = defaultEnabledCipherSuites();
627627
private int sslSessionCacheSize = defaultSslSessionCacheSize();
628628
private int sslSessionTimeout = defaultSslSessionTimeout();
629629
private SslContext sslContext;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
*/
1313
package org.asynchttpclient.config;
1414

15+
import io.netty.handler.ssl.NettySslPackageAccessor;
16+
17+
import java.util.Arrays;
18+
import java.util.Set;
19+
1520
public final class AsyncHttpClientConfigDefaults {
1621

1722
private AsyncHttpClientConfigDefaults() {
@@ -74,6 +79,12 @@ public static String defaultUserAgent() {
7479
public static String[] defaultEnabledProtocols() {
7580
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT + "enabledProtocols");
7681
}
82+
83+
public static String[] defaultEnabledCipherSuites() {
84+
String[] defaultEnabledCipherSuites = AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT + "enabledCipherSuites");
85+
Set<String> supportedCipherSuites = NettySslPackageAccessor.jdkSupportedCipherSuites();
86+
return Arrays.stream(defaultEnabledCipherSuites).filter(supportedCipherSuites::contains).toArray(String[]::new);
87+
}
7788

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ org.asynchttpclient.maxRedirects=5
1212
org.asynchttpclient.compressionEnforced=false
1313
org.asynchttpclient.userAgent=AHC/2.0
1414
org.asynchttpclient.enabledProtocols=TLSv1.2, TLSv1.1, TLSv1
15+
org.asynchttpclient.enabledCipherSuites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
1516
org.asynchttpclient.useProxySelector=false
1617
org.asynchttpclient.useProxyProperties=false
1718
org.asynchttpclient.validateResponseHeaders=true

0 commit comments

Comments
 (0)