Skip to content

Commit c89d51d

Browse files
committed
Authority value determining from sni and whether it is empty or null.
1 parent 1f484a2 commit c89d51d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,16 @@ public AsciiString scheme() {
590590
public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) {
591591
ChannelHandler gnh = new GrpcNegotiationHandler(grpcHandler);
592592
ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger();
593+
String authority;
594+
if ("".equals(sni)) {
595+
authority = null;
596+
} else if (sni != null) {
597+
authority = sni;
598+
} else {
599+
authority = grpcHandler.getAuthority();
600+
}
593601
ChannelHandler cth = new ClientTlsHandler(gnh, sslContext,
594-
sni != null ? sni : grpcHandler.getAuthority(),
595-
this.executor, negotiationLogger, handshakeCompleteRunnable, this,
602+
authority, this.executor, negotiationLogger, handshakeCompleteRunnable, this,
596603
x509ExtendedTrustManager);
597604
return new WaitUntilActiveHandler(cth, negotiationLogger);
598605
}
@@ -630,7 +637,7 @@ static final class ClientTlsHandler extends ProtocolNegotiationHandler {
630637
// TODO: For empty authority and fallback flag
631638
// GRPC_USE_CHANNEL_AUTHORITY_IF_NO_SNI_APPLICABLE present, we should parse authority
632639
// but prevent it from being used for SAN validation in the TrustManager.
633-
if (authority != null && !authority.isEmpty()) {
640+
if (authority != null) {
634641
HostPort hostPort = parseAuthority(authority);
635642
this.host = hostPort.host;
636643
this.port = hostPort.port;

0 commit comments

Comments
 (0)