Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
ed5072e
Add Docker fiels for xds example server and client.
kannanjgithub May 20, 2025
c8be933
Merge branch 'grpc:master' into master
kannanjgithub Jun 3, 2025
63997fd
Merge branch 'grpc:master' into master
kannanjgithub Jun 6, 2025
6263cce
Changes needed for System root certs to work. Commented out the chang…
kannanjgithub Jul 1, 2025
5e794bf
In-progress changes.
kannanjgithub Jul 29, 2025
30ffa7b
Save changes.
kannanjgithub Aug 3, 2025
42c9df0
Save changes.
kannanjgithub Aug 11, 2025
f12bc61
save changed
kannanjgithub Aug 15, 2025
e9c4e3c
Save changes.
kannanjgithub Aug 19, 2025
dd8fa02
Save changes.
kannanjgithub Sep 1, 2025
a371065
Save changes.
kannanjgithub Sep 1, 2025
a6f1bc9
XdsX509TrustManager changes for auto sni san validation.
kannanjgithub Sep 2, 2025
a576df0
Fallback flag when no sni is available to send to specify to use xds …
kannanjgithub Sep 2, 2025
ce1f2d0
Save changes
kannanjgithub Sep 2, 2025
5a4f758
Unit test for auto host sni hostname propagation to ClientSecurityHan…
kannanjgithub Sep 3, 2025
4076998
Save changes.
kannanjgithub Sep 8, 2025
968d564
Save changes.
kannanjgithub Sep 8, 2025
4cf653d
Merge branch 'master' into systemrootcerts-ignore-trusted-root-updates
kannanjgithub Sep 8, 2025
6c1898a
Save changes.
kannanjgithub Sep 8, 2025
5be2aa2
Save changes.
kannanjgithub Sep 8, 2025
90abe55
style
kannanjgithub Sep 9, 2025
4c44e4c
Add comment and rename some confusing method names.
kannanjgithub Sep 9, 2025
ae74a9e
Merge branch 'clientsidenormaltls-systemrootcert-handle' into systemr…
kannanjgithub Sep 9, 2025
199cc69
style.
kannanjgithub Sep 9, 2025
37cd044
Handle Sslcontext updates for System root certs with and without Mtls.
kannanjgithub Sep 10, 2025
14a91e7
Merge branch 'systemrootcerts-ignore-trusted-root-updates' into syste…
kannanjgithub Sep 10, 2025
6958b4e
Merge fixes
kannanjgithub Sep 10, 2025
139805e
Style changes.
kannanjgithub Sep 10, 2025
4417fcc
Fix some mistakes in code.
kannanjgithub Sep 10, 2025
7f48afa
Remove special-casing for System root certs in SslContextProviderSupp…
kannanjgithub Sep 11, 2025
d2b722a
Formatting changes.
kannanjgithub Sep 11, 2025
e116552
Merge branch 'systemrootcerts-ignore-trusted-root-updates' into syste…
kannanjgithub Sep 11, 2025
acb8fa5
Merge with changes to not special case system root certs in SslContex…
kannanjgithub Sep 11, 2025
13200fa
nit
kannanjgithub Sep 11, 2025
e95725d
Trust manager handling for system root certs.
kannanjgithub Sep 11, 2025
180f373
Fix style
kannanjgithub Sep 11, 2025
381beb2
Fixes.
kannanjgithub Sep 11, 2025
18f5d5a
Fix unit tests to cover both mtls and non-mtls for system root certs.
kannanjgithub Sep 11, 2025
e18d6cd
Suppress warning.
kannanjgithub Sep 12, 2025
b8dba99
Merge branch 'systemrootcerts-ignore-trusted-root-updates' into syste…
kannanjgithub Sep 12, 2025
2ecbdb9
Save changes.
kannanjgithub Sep 12, 2025
3845e16
Use non wildcard SAN in the SAN matchers in validation context.
kannanjgithub Sep 12, 2025
825b954
Merge branch 'systemrootcerts-ignore-trusted-root-updates' into syste…
kannanjgithub Sep 12, 2025
0ca4f8b
Save changes.
kannanjgithub Sep 15, 2025
92f3182
Save changes.
kannanjgithub Sep 16, 2025
2f5ba5d
Save changes.
kannanjgithub Sep 17, 2025
2985cc3
Fixes.
kannanjgithub Sep 17, 2025
011a9ea
Allow trustedRootCerts to be present in static CertificateValidationC…
kannanjgithub Sep 17, 2025
b828098
Pass extended trust manager to protocol negotiator.
kannanjgithub Sep 19, 2025
c19a24f
Trust manager not needed on server side when invoking SslProvider.Cal…
kannanjgithub Sep 19, 2025
5ba39b3
Remove whitespace only formatting done by wrong indendation settings …
kannanjgithub Sep 19, 2025
f135943
xds: Plumb system root certs similarly to CertProviders
ejona86 Sep 22, 2025
220e428
Save changes
kannanjgithub Sep 23, 2025
0d5eb0a
Fix certs not updated for handshake.
kannanjgithub Sep 23, 2025
08391fb
Merge branch 'master' into systemrootcerts-ignore-trusted-root-updates
kannanjgithub Sep 23, 2025
d6acdfc
Merge branch 'ejona86_xds_system_cert' into systemrootcerts-ignore-tr…
kannanjgithub Sep 23, 2025
c14a488
More fixes for system root certs.
kannanjgithub Sep 23, 2025
733f57c
More fixes for system root certs.
kannanjgithub Sep 23, 2025
967fe8c
Address review comment to remove reundant if block
kannanjgithub Sep 24, 2025
26733ab
Merge branch 'systemrootcerts-ignore-trusted-root-updates' into syste…
kannanjgithub Sep 24, 2025
9a817f8
Merge from system root certs PR.
kannanjgithub Sep 24, 2025
107cbd8
Some more changes needed after the changes in the base branch.
kannanjgithub Sep 24, 2025
8fa5a78
TrustManager to server name from SslEngine instead of from ProtocolNe…
kannanjgithub Sep 25, 2025
0034d9c
Changes discussed.
kannanjgithub Sep 25, 2025
7219706
Fix plumbings.
kannanjgithub Sep 25, 2025
962df75
Fix plumbings.
kannanjgithub Sep 25, 2025
30cea9a
Fix plumbings.
kannanjgithub Sep 25, 2025
59fe14e
Merge branch 'master' into sni-san-changes
kannanjgithub Sep 25, 2025
1c6066e
static final initialization.
kannanjgithub Sep 25, 2025
348a7a4
Use InternalXdsAttributes for exposing ATTR_ADDRESS_NAME to outside x…
kannanjgithub Sep 25, 2025
c6ca2d4
Use InternalXdsAttributes for exposing ATTR_ADDRESS_NAME to outside x…
kannanjgithub Sep 25, 2025
3f53682
Style fixes.
kannanjgithub Sep 26, 2025
16e4bde
Suppress deprecated warnings.
kannanjgithub Sep 26, 2025
d8544fd
Address review comments.
kannanjgithub Sep 26, 2025
232ca14
Style fixes.
kannanjgithub Sep 26, 2025
fa4e498
Use X509TrustManager everywhere instead of TrustManager, and some oth…
kannanjgithub Sep 26, 2025
a6ee4b2
Style fixes and some minor review comments.
kannanjgithub Sep 26, 2025
1f484a2
Some minor review comments.
kannanjgithub Sep 26, 2025
c89d51d
Authority value determining from sni and whether it is empty or null.
kannanjgithub Sep 26, 2025
d3bd6e2
Remove filters reordering from this PR.
kannanjgithub Sep 26, 2025
0724bc0
Remove 'Internal' prefix from class name InternalXdsAttributes becaus…
kannanjgithub Sep 26, 2025
0d5c141
Style fixes.
kannanjgithub Sep 26, 2025
cd61ddb
Style fixes.
kannanjgithub Sep 26, 2025
ab11c79
Rename package io.grpc.internal in xds project to io.grpc.xds.interna…
kannanjgithub Sep 28, 2025
aff4584
Style fixes.
kannanjgithub Sep 28, 2025
8ba6bfa
Fix a test.
kannanjgithub Sep 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core/src/main/java/io/grpc/internal/CertificateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,29 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.List;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import javax.security.auth.x500.X500Principal;

/**
* Contains certificate/key PEM file utility method(s) for internal usage.
*/
public final class CertificateUtils {
private static final Class<?> x509ExtendedTrustManagerClass;

static {
Class<?> x509ExtendedTrustManagerClass1;
try {
x509ExtendedTrustManagerClass1 = Class.forName("javax.net.ssl.X509ExtendedTrustManager");
} catch (ClassNotFoundException e) {
x509ExtendedTrustManagerClass1 = null;
// Will disallow per-rpc authority override via call option.
}
x509ExtendedTrustManagerClass = x509ExtendedTrustManagerClass1;
}

/**
* Creates X509TrustManagers using the provided CA certs.
*/
Expand Down Expand Up @@ -71,6 +86,17 @@ public static TrustManager[] createTrustManager(InputStream rootCerts)
return trustManagerFactory.getTrustManagers();
}

public static X509TrustManager getX509ExtendedTrustManager(List<TrustManager> trustManagers) {
if (x509ExtendedTrustManagerClass != null) {
for (TrustManager trustManager : trustManagers) {
if (x509ExtendedTrustManagerClass.isInstance(trustManager)) {
return (X509TrustManager) trustManager;
}
}
}
return null;
}

private static X509Certificate[] getX509Certificates(InputStream inputStream)
throws CertificateException {
CertificateFactory factory = CertificateFactory.getInstance("X.509");
Expand Down
17 changes: 11 additions & 6 deletions netty/src/main/java/io/grpc/netty/InternalProtocolNegotiators.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.netty.handler.ssl.SslContext;
import io.netty.util.AsciiString;
import java.util.concurrent.Executor;
import javax.net.ssl.X509TrustManager;

/**
* Internal accessor for {@link ProtocolNegotiators}.
Expand All @@ -42,9 +43,11 @@ private InternalProtocolNegotiators() {}
*/
public static InternalProtocolNegotiator.ProtocolNegotiator tls(SslContext sslContext,
ObjectPool<? extends Executor> executorPool,
Optional<Runnable> handshakeCompleteRunnable) {
Optional<Runnable> handshakeCompleteRunnable,
X509TrustManager extendedX509TrustManager,
String sni) {
final io.grpc.netty.ProtocolNegotiator negotiator = ProtocolNegotiators.tls(sslContext,
executorPool, handshakeCompleteRunnable, null);
executorPool, handshakeCompleteRunnable, extendedX509TrustManager, sni);
final class TlsNegotiator implements InternalProtocolNegotiator.ProtocolNegotiator {

@Override
Expand All @@ -62,17 +65,19 @@ public void close() {
negotiator.close();
}
}

return new TlsNegotiator();
}

/**
* Returns a {@link ProtocolNegotiator} that ensures the pipeline is set up so that TLS will
* be negotiated, the {@code handler} is added and writes to the {@link io.netty.channel.Channel}
* may happen immediately, even before the TLS Handshake is complete.
*/
public static InternalProtocolNegotiator.ProtocolNegotiator tls(SslContext sslContext) {
return tls(sslContext, null, Optional.absent());
public static InternalProtocolNegotiator.ProtocolNegotiator tls(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not an api breaking change? Should we do function overloading here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in an Internal* class, so we are free to make the change. Using overloads is convenient to avoid breaking usages. In this case I expect Kannan thought he was updating all usages (because the usages themselves were the cause of adding the new argument).

FWIW, I also contacted security team and they're looking at deleting the unused internal copy of s2a.

SslContext sslContext, String sni,
X509TrustManager extendedX509TrustManager) {
return tls(sslContext, null, Optional.absent(), extendedX509TrustManager, sni);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ static ProtocolNegotiator createProtocolNegotiatorByType(
case PLAINTEXT_UPGRADE:
return ProtocolNegotiators.plaintextUpgrade();
case TLS:
return ProtocolNegotiators.tls(sslContext, executorPool, Optional.absent(), null);
return ProtocolNegotiators.tls(sslContext, executorPool, Optional.absent(), null, null);
default:
throw new IllegalArgumentException("Unsupported negotiationType: " + negotiationType);
}
Expand Down
73 changes: 40 additions & 33 deletions netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ final class ProtocolNegotiators {
private static final EnumSet<TlsServerCredentials.Feature> understoodServerTlsFeatures =
EnumSet.of(
TlsServerCredentials.Feature.MTLS, TlsServerCredentials.Feature.CUSTOM_MANAGERS);
private static Class<?> x509ExtendedTrustManagerClass;

static {
try {
x509ExtendedTrustManagerClass = Class.forName("javax.net.ssl.X509ExtendedTrustManager");
} catch (ClassNotFoundException e) {
// Will disallow per-rpc authority override via call option.
}
}

private ProtocolNegotiators() {
}
Expand Down Expand Up @@ -147,15 +138,8 @@ public static FromChannelCredentialsResult from(ChannelCredentials creds) {
trustManagers = Arrays.asList(tmf.getTrustManagers());
}
builder.trustManager(new FixedTrustManagerFactory(trustManagers));
TrustManager x509ExtendedTrustManager = null;
if (x509ExtendedTrustManagerClass != null) {
for (TrustManager trustManager : trustManagers) {
if (x509ExtendedTrustManagerClass.isInstance(trustManager)) {
x509ExtendedTrustManager = trustManager;
break;
}
}
}
TrustManager x509ExtendedTrustManager =
CertificateUtils.getX509ExtendedTrustManager(trustManagers);
return FromChannelCredentialsResult.negotiator(tlsClientFactory(builder.build(),
(X509TrustManager) x509ExtendedTrustManager));
} catch (SSLException | GeneralSecurityException ex) {
Expand Down Expand Up @@ -579,20 +563,22 @@ static final class ClientTlsProtocolNegotiator implements ProtocolNegotiator {

public ClientTlsProtocolNegotiator(SslContext sslContext,
ObjectPool<? extends Executor> executorPool, Optional<Runnable> handshakeCompleteRunnable,
X509TrustManager x509ExtendedTrustManager) {
X509TrustManager x509ExtendedTrustManager, String sni) {
this.sslContext = Preconditions.checkNotNull(sslContext, "sslContext");
this.executorPool = executorPool;
if (this.executorPool != null) {
this.executor = this.executorPool.getObject();
}
this.handshakeCompleteRunnable = handshakeCompleteRunnable;
this.x509ExtendedTrustManager = x509ExtendedTrustManager;
this.sni = sni;
}

private final SslContext sslContext;
private final ObjectPool<? extends Executor> executorPool;
private final Optional<Runnable> handshakeCompleteRunnable;
private final X509TrustManager x509ExtendedTrustManager;
private final String sni;
private Executor executor;

@Override
Expand All @@ -604,9 +590,17 @@ public AsciiString scheme() {
public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) {
ChannelHandler gnh = new GrpcNegotiationHandler(grpcHandler);
ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger();
ChannelHandler cth = new ClientTlsHandler(gnh, sslContext, grpcHandler.getAuthority(),
this.executor, negotiationLogger, handshakeCompleteRunnable, this,
x509ExtendedTrustManager);
String authority;
if ("".equals(sni)) {
authority = null;
} else if (sni != null) {
authority = sni;
} else {
authority = grpcHandler.getAuthority();
}
ChannelHandler cth = new ClientTlsHandler(gnh, sslContext,
authority, this.executor, negotiationLogger, handshakeCompleteRunnable, this,
x509ExtendedTrustManager);
return new WaitUntilActiveHandler(cth, negotiationLogger);
}

Expand All @@ -630,28 +624,40 @@ static final class ClientTlsHandler extends ProtocolNegotiationHandler {
private final int port;
private Executor executor;
private final Optional<Runnable> handshakeCompleteRunnable;
private final X509TrustManager x509ExtendedTrustManager;
private final X509TrustManager x509TrustManager;
private SSLEngine sslEngine;

ClientTlsHandler(ChannelHandler next, SslContext sslContext, String authority,
Executor executor, ChannelLogger negotiationLogger,
Optional<Runnable> handshakeCompleteRunnable,
ClientTlsProtocolNegotiator clientTlsProtocolNegotiator,
X509TrustManager x509ExtendedTrustManager) {
X509TrustManager x509TrustManager) {
super(next, negotiationLogger);
this.sslContext = Preconditions.checkNotNull(sslContext, "sslContext");
HostPort hostPort = parseAuthority(authority);
this.host = hostPort.host;
this.port = hostPort.port;
// TODO: For empty authority and fallback flag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half-baked thought (I haven't double checked with the expected behavior): it seems we should just pass sni = null here instead of empty string when GRPC_USE_CHANNEL_AUTHORITY_IF_NO_SNI_APPLICABLE is set. If the XDS config is saying to validate the SAN from the SNI and it also dosen't have a hostname, then that's a rather minor case that might pass when it should fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could either pass empty SNI here and change it to null when fallback flag is set (which is what I was going to do), or we could do that in the calling site at ClientTlsProtocolNegotiator itself and pass a null SNI in that case. The bigger question is at the time of SAN validation do we get the xDS channel authority from the SsllParameters.getServerNames(), and if so we should not use it for the SAN validation, and that would require setting some state in the XdsX509TrustManager.

// GRPC_USE_CHANNEL_AUTHORITY_IF_NO_SNI_APPLICABLE present, we should parse authority
// but prevent it from being used for SAN validation in the TrustManager.
if (authority != null) {
HostPort hostPort = parseAuthority(authority);
this.host = hostPort.host;
this.port = hostPort.port;
} else {
this.host = null;
this.port = 0;
}
this.executor = executor;
this.handshakeCompleteRunnable = handshakeCompleteRunnable;
this.x509ExtendedTrustManager = x509ExtendedTrustManager;
this.x509TrustManager = x509TrustManager;
}

@Override
@IgnoreJRERequirement
protected void handlerAdded0(ChannelHandlerContext ctx) {
sslEngine = sslContext.newEngine(ctx.alloc(), host, port);
if (host != null) {
sslEngine = sslContext.newEngine(ctx.alloc(), host, port);
} else {
sslEngine = sslContext.newEngine(ctx.alloc());
}
SSLParameters sslParams = sslEngine.getSSLParameters();
sslParams.setEndpointIdentificationAlgorithm("HTTPS");
sslEngine.setSSLParameters(sslParams);
Expand Down Expand Up @@ -709,7 +715,7 @@ private void propagateTlsComplete(ChannelHandlerContext ctx, SSLSession session)
.set(GrpcAttributes.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY)
.set(Grpc.TRANSPORT_ATTR_SSL_SESSION, session)
.set(GrpcAttributes.ATTR_AUTHORITY_VERIFIER, new X509AuthorityVerifier(
sslEngine, x509ExtendedTrustManager))
sslEngine, x509TrustManager))
.build();
replaceProtocolNegotiationEvent(existingPne.withAttributes(attrs).withSecurity(security));
if (handshakeCompleteRunnable.isPresent()) {
Expand Down Expand Up @@ -746,13 +752,14 @@ static HostPort parseAuthority(String authority) {
* Returns a {@link ProtocolNegotiator} that ensures the pipeline is set up so that TLS will
* be negotiated, the {@code handler} is added and writes to the {@link io.netty.channel.Channel}
* may happen immediately, even before the TLS Handshake is complete.
*
* @param executorPool a dedicated {@link Executor} pool for time-consuming TLS tasks
*/
public static ProtocolNegotiator tls(SslContext sslContext,
ObjectPool<? extends Executor> executorPool, Optional<Runnable> handshakeCompleteRunnable,
X509TrustManager x509ExtendedTrustManager) {
X509TrustManager x509ExtendedTrustManager, String sni) {
return new ClientTlsProtocolNegotiator(sslContext, executorPool, handshakeCompleteRunnable,
x509ExtendedTrustManager);
x509ExtendedTrustManager, sni);
}

/**
Expand All @@ -762,7 +769,7 @@ public static ProtocolNegotiator tls(SslContext sslContext,
*/
public static ProtocolNegotiator tls(SslContext sslContext,
X509TrustManager x509ExtendedTrustManager) {
return tls(sslContext, null, Optional.absent(), x509ExtendedTrustManager);
return tls(sslContext, null, Optional.absent(), x509ExtendedTrustManager, null);
}

public static ProtocolNegotiator.ClientFactory tlsClientFactory(SslContext sslContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ public void tlsNegotiationServerExecutorShouldSucceed() throws Exception {
.keyManager(clientCert, clientKey)
.build();
ProtocolNegotiator negotiator = ProtocolNegotiators.tls(clientContext, clientExecutorPool,
Optional.absent(), null);
Optional.absent(), null, null);
// after starting the client, the Executor in the client pool should be used
assertEquals(true, clientExecutorPool.isInUse());
final NettyClientTransport transport = newTransport(negotiator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public void clientTlsHandler_closeDuringNegotiation() throws Exception {
private ClientTlsProtocolNegotiator getClientTlsProtocolNegotiator() throws SSLException {
return new ClientTlsProtocolNegotiator(GrpcSslContexts.forClient().trustManager(
TlsTesting.loadCert("ca.pem")).build(),
null, Optional.absent(), null);
null, Optional.absent(), null, "");
}

@Test
Expand Down Expand Up @@ -1277,7 +1277,7 @@ public void clientTlsHandler_firesNegotiation() throws Exception {
}
FakeGrpcHttp2ConnectionHandler gh = FakeGrpcHttp2ConnectionHandler.newHandler();
ClientTlsProtocolNegotiator pn = new ClientTlsProtocolNegotiator(clientSslContext,
null, Optional.absent(), null);
null, Optional.absent(), null, null);
WriteBufferingAndExceptionHandler clientWbaeh =
new WriteBufferingAndExceptionHandler(pn.newHandler(gh));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator;
import io.grpc.netty.InternalProtocolNegotiators;
import io.grpc.netty.InternalProtocolNegotiators.ProtocolNegotiationHandler;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
Expand Down Expand Up @@ -259,7 +258,8 @@ public void onSuccess(SslContext sslContext) {
public void run() {
s2aStub.close();
}
}))
}),
null, null)
.newHandler(grpcHandler);

// Delegate the rest of the handshake to the TLS handler. and remove the
Expand Down
15 changes: 8 additions & 7 deletions xds/src/main/java/io/grpc/xds/ClusterImplLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.grpc.xds.client.XdsClient;
import io.grpc.xds.client.XdsLogger;
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
import io.grpc.xds.internal.XdsInternalAttributes;
import io.grpc.xds.internal.security.SecurityProtocolNegotiators;
import io.grpc.xds.internal.security.SslContextProviderSupplier;
import io.grpc.xds.orca.OrcaPerRequestUtil;
Expand Down Expand Up @@ -117,12 +118,12 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
logger.log(XdsLogLevel.DEBUG, "Received resolution result: {0}", resolvedAddresses);
Attributes attributes = resolvedAddresses.getAttributes();
if (xdsClientPool == null) {
xdsClientPool = attributes.get(XdsAttributes.XDS_CLIENT_POOL);
xdsClientPool = attributes.get(io.grpc.xds.XdsAttributes.XDS_CLIENT_POOL);
assert xdsClientPool != null;
xdsClient = xdsClientPool.getObject();
}
if (callCounterProvider == null) {
callCounterProvider = attributes.get(XdsAttributes.CALL_COUNTER_PROVIDER);
callCounterProvider = attributes.get(io.grpc.xds.XdsAttributes.CALL_COUNTER_PROVIDER);
}

ClusterImplConfig config =
Expand Down Expand Up @@ -241,9 +242,9 @@ public Subchannel createSubchannel(CreateSubchannelArgs args) {
.set(ATTR_CLUSTER_LOCALITY, localityAtomicReference);
if (GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE", false)) {
String hostname = args.getAddresses().get(0).getAttributes()
.get(XdsAttributes.ATTR_ADDRESS_NAME);
.get(XdsInternalAttributes.ATTR_ADDRESS_NAME);
if (hostname != null) {
attrsBuilder.set(XdsAttributes.ATTR_ADDRESS_NAME, hostname);
attrsBuilder.set(XdsInternalAttributes.ATTR_ADDRESS_NAME, hostname);
}
}
args = args.toBuilder().setAddresses(addresses).setAttributes(attrsBuilder.build()).build();
Expand Down Expand Up @@ -292,7 +293,7 @@ private List<EquivalentAddressGroup> withAdditionalAttributes(
List<EquivalentAddressGroup> newAddresses = new ArrayList<>();
for (EquivalentAddressGroup eag : addresses) {
Attributes.Builder attrBuilder = eag.getAttributes().toBuilder().set(
XdsAttributes.ATTR_CLUSTER_NAME, cluster);
io.grpc.xds.XdsAttributes.ATTR_CLUSTER_NAME, cluster);
if (sslContextProviderSupplier != null) {
attrBuilder.set(
SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER,
Expand All @@ -304,7 +305,7 @@ private List<EquivalentAddressGroup> withAdditionalAttributes(
}

private ClusterLocality createClusterLocalityFromAttributes(Attributes addressAttributes) {
Locality locality = addressAttributes.get(XdsAttributes.ATTR_LOCALITY);
Locality locality = addressAttributes.get(io.grpc.xds.XdsAttributes.ATTR_LOCALITY);
String localityName = addressAttributes.get(EquivalentAddressGroup.ATTR_LOCALITY_NAME);

// Endpoint addresses resolved by ClusterResolverLoadBalancer should always contain
Expand Down Expand Up @@ -438,7 +439,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
result = PickResult.withSubchannel(result.getSubchannel(),
result.getStreamTracerFactory(),
result.getSubchannel().getAttributes().get(
XdsAttributes.ATTR_ADDRESS_NAME));
XdsInternalAttributes.ATTR_ADDRESS_NAME));
}
}
return result;
Expand Down
Loading