From 1d8d7d70fe812fad7707536cf36390403cb00085 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 31 Jan 2017 16:38:08 -0800 Subject: [PATCH] interop-testing: overrideAuthority breaks JWT Commit 65e4d9f4 caused grpc/grpc#9497 and #2680 (dup). It is believed to be because the JWT does not see the authority passed to overrideAuthority. So the changes to interop-testing client are temporarily reverted here. Note that this breaks GRPC_PROXY_EXP testing, so the incompatibility needs to be resolved. Solving #2682 will allow reverting this change. --- .../testing/integration/TestServiceClient.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java index 85f89e8c10cb..e9f2e7d8f805 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java @@ -43,6 +43,9 @@ import io.netty.handler.ssl.SslContext; import java.io.File; import java.io.FileInputStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.UnknownHostException; import java.nio.charset.Charset; import javax.net.ssl.SSLSocketFactory; @@ -301,6 +304,16 @@ private class Tester extends AbstractInteropTest { @Override protected ManagedChannel createChannel() { if (!useOkHttp) { + InetAddress address; + try { + address = InetAddress.getByName(serverHost); + if (serverHostOverride != null) { + // Force the hostname to match the cert the server uses. + address = InetAddress.getByAddress(serverHostOverride, address.getAddress()); + } + } catch (UnknownHostException ex) { + throw new RuntimeException(ex); + } SslContext sslContext = null; if (useTestCa) { try { @@ -310,8 +323,7 @@ protected ManagedChannel createChannel() { throw new RuntimeException(ex); } } - return NettyChannelBuilder.forAddress(serverHost, serverPort) - .overrideAuthority(serverHostOverride) + return NettyChannelBuilder.forAddress(new InetSocketAddress(address, serverPort)) .flowControlWindow(65 * 1024) .negotiationType(useTls ? NegotiationType.TLS : NegotiationType.PLAINTEXT) .sslContext(sslContext)