Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78a64f4

Browse files
committed
Drop NettySslPackageAccessor,closeAsyncHttpClient#1382
Motivation:* mess up with provided SslContext* crash when netty and ahc are in different classloadersModifications:* Drop NettySslPackageAccessor* Revert to empty conf to use Netty default behavior (only Nettyrecommended ciphers are available by default)Result:Don’t override provided SslContext behavior.No more crash when netty and ahc sits in different classloaders
1 parentcec67cf commit78a64f4

File tree

6 files changed

+24
-46
lines changed

6 files changed

+24
-46
lines changed

‎client/src/main/java/io/netty/handler/ssl/NettySslPackageAccessor.java‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
*/
1313
packageorg.asynchttpclient.config;
1414

15-
importio.netty.handler.ssl.NettySslPackageAccessor;
16-
17-
importjava.util.Arrays;
18-
importjava.util.Set;
1915

2016
publicfinalclassAsyncHttpClientConfigDefaults {
2117

@@ -81,9 +77,7 @@ public static String[] defaultEnabledProtocols() {
8177
}
8278

8379
publicstaticString[]defaultEnabledCipherSuites() {
84-
String[]defaultEnabledCipherSuites =AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT +"enabledCipherSuites");
85-
Set<String>supportedCipherSuites =NettySslPackageAccessor.jdkSupportedCipherSuites();
86-
returnArrays.stream(defaultEnabledCipherSuites).filter(supportedCipherSuites::contains).toArray(String[]::new);
80+
returnAsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT +"enabledCipherSuites");
8781
}
8882

8983
publicstaticbooleandefaultUseProxySelector() {

‎client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigHelper.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public String getString(String key) {
9494

9595
publicString[]getStringArray(Stringkey) {
9696
Strings =getString(key);
97+
s =s.trim();
98+
if (s.isEmpty()) {
99+
returnnull;
100+
}
97101
String[]rawArray =s.split(",");
98102
String[]array =newString[rawArray.length];
99103
for (inti =0;i <rawArray.length;i++)

‎client/src/main/java/org/asynchttpclient/netty/ssl/DefaultSslEngineFactory.java‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
*/
1414
packageorg.asynchttpclient.netty.ssl;
1515

16+
importstaticorg.asynchttpclient.util.MiscUtils.*;
17+
1618
importio.netty.buffer.ByteBufAllocator;
1719
importio.netty.handler.ssl.SslContext;
1820
importio.netty.handler.ssl.SslContextBuilder;
1921
importio.netty.handler.ssl.SslProvider;
2022

23+
importjava.util.Arrays;
24+
2125
importjavax.net.ssl.SSLEngine;
2226
importjavax.net.ssl.SSLException;
2327

@@ -28,16 +32,26 @@ public class DefaultSslEngineFactory extends SslEngineFactoryBase {
2832
privatevolatileSslContextsslContext;
2933

3034
privateSslContextbuildSslContext(AsyncHttpClientConfigconfig)throwsSSLException {
31-
if (config.getSslContext() !=null)
35+
if (config.getSslContext() !=null) {
3236
returnconfig.getSslContext();
37+
}
3338

3439
SslContextBuildersslContextBuilder =SslContextBuilder.forClient()//
3540
.sslProvider(config.isUseOpenSsl() ?SslProvider.OPENSSL :SslProvider.JDK)//
3641
.sessionCacheSize(config.getSslSessionCacheSize())//
3742
.sessionTimeout(config.getSslSessionTimeout());
3843

39-
if (config.isAcceptAnyCertificate())
44+
if (isNonEmpty(config.getEnabledProtocols())) {
45+
sslContextBuilder.protocols(config.getEnabledProtocols());
46+
}
47+
48+
if (isNonEmpty(config.getEnabledCipherSuites())) {
49+
sslContextBuilder.ciphers(Arrays.asList(config.getEnabledCipherSuites()));
50+
}
51+
52+
if (config.isAcceptAnyCertificate()) {
4053
sslContextBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
54+
}
4155

4256
returnconfigureSslContextBuilder(sslContextBuilder).build();
4357
}
@@ -56,8 +70,8 @@ public void init(AsyncHttpClientConfig config) throws SSLException {
5670
}
5771

5872
/**
59-
* The last step of configuring the SslContextBuilder used to create an SslContext when no context is provided in
60-
*the {@link AsyncHttpClientConfig}. This defaults to no-op andis intended to be overridden as needed.
73+
* The last step of configuring the SslContextBuilder used to create an SslContext when no context is provided in the {@link AsyncHttpClientConfig}. This defaults to no-op and
74+
* is intended to be overridden as needed.
6175
*
6276
* @param builder builder with normal configuration applied
6377
* @return builder to be used to build context (can be the same object as the input)

‎client/src/main/java/org/asynchttpclient/netty/ssl/SslEngineFactoryBase.java‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
packageorg.asynchttpclient.netty.ssl;
1515

16-
importstaticorg.asynchttpclient.util.MiscUtils.isNonEmpty;
17-
1816
importjavax.net.ssl.SSLEngine;
1917
importjavax.net.ssl.SSLParameters;
2018

@@ -28,11 +26,5 @@ protected void configureSslEngine(SSLEngine sslEngine, AsyncHttpClientConfig con
2826
SSLParametersparams =sslEngine.getSSLParameters();
2927
params.setEndpointIdentificationAlgorithm("HTTPS");
3028
sslEngine.setSSLParameters(params);
31-
32-
if (isNonEmpty(config.getEnabledProtocols()))
33-
sslEngine.setEnabledProtocols(config.getEnabledProtocols());
34-
35-
if (isNonEmpty(config.getEnabledCipherSuites()))
36-
sslEngine.setEnabledCipherSuites(config.getEnabledCipherSuites());
3729
}
3830
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +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_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,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
15+
org.asynchttpclient.enabledCipherSuites=
1616
org.asynchttpclient.useProxySelector=false
1717
org.asynchttpclient.useProxyProperties=false
1818
org.asynchttpclient.validateResponseHeaders=true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp