GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Auto-port 5.0: Fail the handshake if the certificate callback task th… · netty/netty@e56d55b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-classes-quic/src/main/java/io/netty/handler/codec/quic
    • BoringSSLCertificateCallbackTask.java
  • codec-native-quic/src/test/java/io/netty/handler/codec/quic
    • QuicChannelConnectTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLCertificateCallbackTask.java‎

Copy file name to clipboardExpand all lines: codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLCertificateCallbackTask.java
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ protected void runTask(long ssl, TaskCallback taskCallback) {
5151
this.chain = result[1];
5252
taskCallback.onResult(ssl, 1);
5353
}
54-
} catch (Exception e) {
55-
// Just catch the exception and return 0 to fail the handshake.
54+
} catch (Throwable cause) {
55+
// Just catch the Throwable and return 0 to fail the handshake.
5656
// The problem is that rethrowing here is really "useless" as we will process it as part of an openssl
5757
// c callback which needs to return 0 for an error to abort the handshake.
58+
// We also need to catch Errors (for example thrown by a user supplied KeyManager) as otherwise the task
59+
// would never complete and the handshake would stall instead of failing.
5860
taskCallback.onResult(ssl, 0);
5961
}
6062
}
Collapse file

‎codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java‎

Copy file name to clipboardExpand all lines: codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java
+72Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292

9393
import static org.assertj.core.api.Assertions.assertThat;
9494
import static org.junit.jupiter.api.Assertions.assertEquals;
95+
import static org.junit.jupiter.api.Assertions.assertFalse;
9596
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
9697
import static org.junit.jupiter.api.Assertions.assertNotEquals;
9798
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -1908,6 +1909,77 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
19081909
}
19091910
}
19101911

1912+
@ParameterizedTest
1913+
@MethodSource("newSslTaskExecutors")
1914+
public void testConnectFailsIfKeyManagerThrowsError(Executor executor) throws Throwable {
1915+
AtomicBoolean keyManagerCalled = new AtomicBoolean();
1916+
X509ExtendedKeyManager keyManager = new X509ExtendedKeyManager() {
1917+
@Override
1918+
public String[] getClientAliases(String keyType, Principal[] issuers) {
1919+
return null;
1920+
}
1921+
1922+
@Override
1923+
public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
1924+
return null;
1925+
}
1926+
1927+
@Override
1928+
public String[] getServerAliases(String keyType, Principal[] issuers) {
1929+
return null;
1930+
}
1931+
1932+
@Override
1933+
public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
1934+
return null;
1935+
}
1936+
1937+
@Override
1938+
public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) {
1939+
keyManagerCalled.set(true);
1940+
// An Error (and not an Exception) must also fail the handshake and not stall it.
1941+
throw new NoClassDefFoundError("expected");
1942+
}
1943+
1944+
@Override
1945+
public X509Certificate[] getCertificateChain(String alias) {
1946+
throw new UnsupportedOperationException();
1947+
}
1948+
1949+
@Override
1950+
public PrivateKey getPrivateKey(String alias) {
1951+
throw new UnsupportedOperationException();
1952+
}
1953+
};
1954+
1955+
Channel server = QuicTestUtils.newServer(QuicTestUtils.newQuicServerBuilder(executor,
1956+
QuicSslContextBuilder.forServer(keyManager, null)
1957+
.applicationProtocols(QuicTestUtils.PROTOS).clientAuth(ClientAuth.NONE).build()),
1958+
TestQuicTokenHandler.INSTANCE, new TestHandler(),
1959+
new TestHandler());
1960+
InetSocketAddress address = (InetSocketAddress) server.localAddress();
1961+
1962+
Channel channel = QuicTestUtils.newClient(QuicTestUtils.newQuicClientBuilder(executor,
1963+
QuicSslContextBuilder.forClient()
1964+
.trustManager(InsecureTrustManagerFactory.INSTANCE)
1965+
.applicationProtocols(QuicTestUtils.PROTOS).build()));
1966+
try {
1967+
Future<QuicChannel> connectFuture = QuicTestUtils.newQuicChannelBootstrap(channel)
1968+
.handler(new TestHandler())
1969+
.streamHandler(new TestHandler())
1970+
.remoteAddress(address)
1971+
.connect().await();
1972+
assertFalse(connectFuture.isSuccess());
1973+
assertTrue(keyManagerCalled.get());
1974+
} finally {
1975+
server.close().sync();
1976+
// Close the parent Datagram channel as well.
1977+
channel.close().sync();
1978+
1979+
shutdown(executor);
1980+
}
1981+
}
1982+
19111983
@ParameterizedTest
19121984
@MethodSource("newSslTaskExecutors")
19131985
public void testSessionTickets(Executor executor) throws Throwable {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.