|
44 | 44 | import io.grpc.testing.protobuf.SimpleResponse; |
45 | 45 | import io.grpc.testing.protobuf.SimpleServiceGrpc; |
46 | 46 | import io.netty.handler.ssl.ClientAuth; |
| 47 | +import io.netty.handler.ssl.OpenSslContextOption; |
47 | 48 | import io.netty.handler.ssl.OpenSslSessionContext; |
48 | 49 | import io.netty.handler.ssl.SslContext; |
49 | 50 | import io.netty.handler.ssl.SslContextBuilder; |
@@ -253,4 +254,41 @@ public void unaryRpc(SimpleRequest request, StreamObserver<SimpleResponse> obser |
253 | 254 | observer.onCompleted(); |
254 | 255 | } |
255 | 256 | } |
| 257 | + |
| 258 | + @Test |
| 259 | + public void clientCommunicateWithPqcRequiredServer_succeeds() throws Exception { |
| 260 | + ClassLoader classLoader = IntegrationTest.class.getClassLoader(); |
| 261 | + SslContextBuilder serverSslContextBuilder = |
| 262 | + SslContextBuilder.forServer( |
| 263 | + classLoader.getResourceAsStream("cert_chain_ec.pem"), |
| 264 | + classLoader.getResourceAsStream("leaf_key_ec.pem")); |
| 265 | + SslContext serverSslContext = |
| 266 | + GrpcSslContexts.configure(serverSslContextBuilder, SslProvider.OPENSSL) |
| 267 | + .protocols("TLSv1.3") |
| 268 | + .trustManager(classLoader.getResourceAsStream("root_cert_ec.pem")) |
| 269 | + .clientAuth(ClientAuth.REQUIRE) |
| 270 | + .option(OpenSslContextOption.GROUPS, new String[] {"X25519MLKEM768"}) |
| 271 | + .build(); |
| 272 | + |
| 273 | + Server pqcServer = |
| 274 | + NettyServerBuilder.forPort(0) |
| 275 | + .addService(new SimpleServiceImpl()) |
| 276 | + .sslContext(serverSslContext) |
| 277 | + .build() |
| 278 | + .start(); |
| 279 | + int pqcServerPort = pqcServer.getPort(); |
| 280 | + String pqcServerAddress = "localhost:" + pqcServerPort; |
| 281 | + |
| 282 | + try { |
| 283 | + ChannelCredentials credentials = |
| 284 | + S2AChannelCredentials.newBuilder(s2aAddress, InsecureChannelCredentials.create()) |
| 285 | + .setLocalSpiffeId("test-spiffe-id").build(); |
| 286 | + ManagedChannel channel = Grpc.newChannelBuilder(pqcServerAddress, credentials).build(); |
| 287 | + |
| 288 | + assertThat(doUnaryRpc(channel)).isTrue(); |
| 289 | + } finally { |
| 290 | + pqcServer.shutdown(); |
| 291 | + pqcServer.awaitTermination(10, SECONDS); |
| 292 | + } |
| 293 | + } |
256 | 294 | } |
0 commit comments