Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALPN H2 Support for Netty Client #5794

Merged
merged 24 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
050d7ce
ALPN H2 support in Netty client
davidh44 Jan 14, 2025
815a0da
Add codegen customizations to skip ALPN for existing H2 services
davidh44 Jan 14, 2025
6df6a6c
Add changelog
davidh44 Jan 14, 2025
1a01e77
Add benchmarks
davidh44 Jan 14, 2025
1e99886
Add tests
davidh44 Jan 14, 2025
93d096a
Update test
davidh44 Jan 14, 2025
b557813
Update test
davidh44 Jan 14, 2025
59c8096
Address comments
davidh44 Jan 14, 2025
d54d3ac
Update test file name
davidh44 Jan 14, 2025
a0eab5f
Revert to checking Java version for ALPN support
davidh44 Jan 15, 2025
86b6638
Update Kinesis integ tests
davidh44 Jan 15, 2025
d2b2d3a
Propagate exception and close channel
davidh44 Jan 15, 2025
deb0bcd
Add tests and update ALPN support check for OpenSsl
davidh44 Jan 15, 2025
c041db7
Set max streams when completing protocol future
davidh44 Jan 15, 2025
5b60892
Add test dependencies
davidh44 Jan 15, 2025
40c3bfc
Do not use FATAL_ALERT if OpenSSL is used
davidh44 Jan 16, 2025
65353bb
Remove completing future in ALPN handler
davidh44 Jan 17, 2025
a3af0ca
Remove import
davidh44 Jan 17, 2025
f79e297
Merge branch 'master' into feature/master/alpn-h2-netty-client
davidh44 Jan 21, 2025
6caf668
Update ALPN support check to check for getApplicationProtocol method …
davidh44 Jan 21, 2025
0629830
Address comments
davidh44 Jan 22, 2025
1dca786
Merge branch 'master' into feature/master/alpn-h2-netty-client
davidh44 Jan 22, 2025
422b6ab
Use Lazy for alpn support check
davidh44 Jan 22, 2025
edee03f
Merge branch 'master' into feature/master/alpn-h2-netty-client
davidh44 Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update ALPN support check to check for getApplicationProtocol method …
…in SSLEngine
davidh44 committed Jan 21, 2025
commit 6caf668c0abab1b9fb1a0f08892c40b83ea8877d
Original file line number Diff line number Diff line change
@@ -32,14 +32,20 @@
import io.netty.util.concurrent.Promise;
import io.netty.util.concurrent.SucceededFuture;
import java.io.IOException;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.nio.channels.ClosedChannelException;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLParameters;
import software.amazon.awssdk.annotations.SdkInternalApi;
@@ -396,20 +402,26 @@ public static boolean isAlpnSupported(SslProvider sslProvider) {
if (sslProvider != SslProvider.JDK) {
return true;
}
String javaVersion = getJavaVersion();
String[] versionComponents = javaVersion.split("_");
if (versionComponents.length == 2) {
try {
int buildNumber = Integer.parseInt(versionComponents[1].split("-")[0]);
if (javaVersion.startsWith("1.8.0") && buildNumber < 251) {
return false;
}
} catch (NumberFormatException e) {
log.info(() -> "Invalid Java version format: " + javaVersion);
throw e;
}

try {
SSLContext context = SSLContext.getInstance("TLS");
davidh44 marked this conversation as resolved.
Show resolved Hide resolved
context.init(null, null, null);
SSLEngine engine = context.createSSLEngine();
MethodHandles.Lookup lookup = MethodHandles.lookup();

MethodHandle getApplicationProtocol = AccessController.doPrivileged(
(PrivilegedExceptionAction<MethodHandle>) () ->
lookup.findVirtual(SSLEngine.class, "getApplicationProtocol", MethodType.methodType(String.class)));

getApplicationProtocol.invoke(engine);
return true;
} catch (NoSuchMethodException e) {
log.info(() -> "ALPN not supported: SSLEngine.getApplicationProtocol() method not found.");
davidh44 marked this conversation as resolved.
Show resolved Hide resolved
return false;
} catch (Throwable t) {
log.info(() -> "ALPN support check failed: " + t.getMessage());
davidh44 marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
return true;
}

public static String getJavaVersion() {