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 85f89e8c10c..e9f2e7d8f80 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)