Skip to content

Commit 3f53682

Browse files
committed
Style fixes.
1 parent c6ca2d4 commit 3f53682

20 files changed

+213
-275
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.common.annotations.VisibleForTesting;
2222
import com.google.common.base.Optional;
2323
import com.google.common.base.Preconditions;
24-
import com.google.common.base.Strings;
2524
import com.google.errorprone.annotations.ForOverride;
2625
import io.grpc.Attributes;
2726
import io.grpc.CallCredentials;
@@ -592,7 +591,7 @@ public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) {
592591
ChannelHandler gnh = new GrpcNegotiationHandler(grpcHandler);
593592
ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger();
594593
ChannelHandler cth = new ClientTlsHandler(gnh, sslContext,
595-
sni != null? sni : grpcHandler.getAuthority(),
594+
sni != null ? sni : grpcHandler.getAuthority(),
596595
this.executor, negotiationLogger, handshakeCompleteRunnable, null,
597596
x509ExtendedTrustManager);
598597
return new WaitUntilActiveHandler(cth, negotiationLogger);

xds/src/main/java/io/grpc/xds/XdsAttributes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ final class XdsAttributes {
8888
static final Attributes.Key<Long> ATTR_SERVER_WEIGHT =
8989
Attributes.Key.create("io.grpc.xds.XdsAttributes.serverWeight");
9090

91-
/** Name associated with individual address, if available (e.g., DNS name). */
92-
@EquivalentAddressGroup.Attr
93-
static final Attributes.Key<String> ATTR_ADDRESS_NAME =
94-
Attributes.Key.create("io.grpc.xds.XdsAttributes.addressName");
91+
/** Name associated with individual address, if available (e.g., DNS name). */
92+
@EquivalentAddressGroup.Attr
93+
static final Attributes.Key<String> ATTR_ADDRESS_NAME =
94+
Attributes.Key.create("io.grpc.xds.XdsAttributes.addressName");
9595

9696
/**
9797
* Filter chain match for network filters.

xds/src/main/java/io/grpc/xds/internal/security/ClientSslContextProviderFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.grpc.xds.client.Bootstrapper.BootstrapInfo;
2121
import io.grpc.xds.internal.security.ReferenceCountingMap.ValueFactory;
2222
import io.grpc.xds.internal.security.certprovider.CertProviderClientSslContextProviderFactory;
23-
import java.util.AbstractMap;
2423

2524
/** Factory to create client-side SslContextProvider from UpstreamTlsContext. */
2625
final class ClientSslContextProviderFactory

xds/src/main/java/io/grpc/xds/internal/security/DynamicSslContextProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ protected DynamicSslContextProvider(
5353

5454
@Nullable
5555
public AbstractMap.SimpleImmutableEntry<SslContext, TrustManager>
56-
getSslContextAndTrustManager() {
56+
getSslContextAndTrustManager() {
5757
return sslContextAndTrustManager;
5858
}
5959

6060
protected abstract CertificateValidationContext generateCertificateValidationContext();
6161

6262
/** Gets a server or client side SslContextBuilder. */
6363
protected abstract AbstractMap.SimpleImmutableEntry<SslContextBuilder, TrustManager>
64-
getSslContextBuilderAndTrustManager(
64+
getSslContextBuilderAndTrustManager(
6565
CertificateValidationContext certificateValidationContext)
6666
throws CertificateException, IOException, CertStoreException;
6767

xds/src/main/java/io/grpc/xds/internal/security/SecurityProtocolNegotiators.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.common.annotations.VisibleForTesting;
2222
import com.google.common.base.Strings;
2323
import io.grpc.Attributes;
24-
import io.grpc.EquivalentAddressGroup;
2524
import io.grpc.Grpc;
2625
import io.grpc.internal.GrpcUtil;
2726
import io.grpc.internal.ObjectPool;

xds/src/main/java/io/grpc/xds/internal/security/SslContextProviderSupplier.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
import io.grpc.xds.TlsContextManager;
2727
import io.netty.handler.ssl.SslContext;
2828
import java.util.AbstractMap;
29-
import java.util.HashSet;
3029
import java.util.Objects;
31-
import java.util.Set;
3230
import javax.net.ssl.TrustManager;
3331

3432
/**
@@ -104,8 +102,8 @@ private void releaseSslContextProvider(SslContextProvider toRelease) {
104102
private SslContextProvider getSslContextProvider() {
105103
return tlsContext instanceof UpstreamTlsContext
106104
? tlsContextManager.findOrCreateClientSslContextProvider((UpstreamTlsContext) tlsContext)
107-
: tlsContextManager.findOrCreateServerSslContextProvider
108-
((DownstreamTlsContext) tlsContext);
105+
: tlsContextManager.findOrCreateServerSslContextProvider(
106+
(DownstreamTlsContext) tlsContext);
109107
}
110108

111109
@VisibleForTesting public boolean isShutdown() {

xds/src/main/java/io/grpc/xds/internal/security/TlsContextManagerImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public SslContextProvider findOrCreateServerSslContextProvider(
7171
public SslContextProvider findOrCreateClientSslContextProvider(
7272
UpstreamTlsContext upstreamTlsContext) {
7373
checkNotNull(upstreamTlsContext, "upstreamTlsContext");
74-
CommonTlsContext.Builder builder = upstreamTlsContext.getCommonTlsContext().toBuilder();
75-
upstreamTlsContext = new UpstreamTlsContext(builder.build());
7674
return mapForClients.get(upstreamTlsContext);
7775
}
7876

xds/src/main/java/io/grpc/xds/internal/security/certprovider/CertProviderClientSslContextProvider.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,22 @@ final class CertProviderClientSslContextProvider extends CertProviderSslContextP
5555

5656
@Override
5757
protected final AbstractMap.SimpleImmutableEntry<SslContextBuilder, TrustManager>
58-
getSslContextBuilderAndTrustManager(
58+
getSslContextBuilderAndTrustManager(
5959
CertificateValidationContext certificateValidationContext)
6060
throws CertStoreException {
6161
SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
6262
if (savedSpiffeTrustMap != null) {
6363
sslContextBuilder = sslContextBuilder.trustManager(
6464
new XdsTrustManagerFactory(
6565
savedSpiffeTrustMap,
66-
certificateValidationContext, ((UpstreamTlsContext) tlsContext).getAutoSniSanValidation()));
66+
certificateValidationContext,
67+
((UpstreamTlsContext) tlsContext).getAutoSniSanValidation()));
6768
} else if (savedTrustedRoots != null) {
6869
sslContextBuilder = sslContextBuilder.trustManager(
6970
new XdsTrustManagerFactory(
7071
savedTrustedRoots.toArray(new X509Certificate[0]),
71-
certificateValidationContext, ((UpstreamTlsContext) tlsContext).getAutoSniSanValidation()));
72+
certificateValidationContext,
73+
((UpstreamTlsContext) tlsContext).getAutoSniSanValidation()));
7274
} else {
7375
// Should be impossible because of the check in CertProviderClientSslContextProviderFactory
7476
throw new IllegalStateException("There must be trusted roots or a SPIFFE trust map");
@@ -77,12 +79,14 @@ final class CertProviderClientSslContextProvider extends CertProviderSslContextP
7779
if (savedSpiffeTrustMap != null) {
7880
trustManagerFactory = new XdsTrustManagerFactory(
7981
savedSpiffeTrustMap,
80-
certificateValidationContext, ((UpstreamTlsContext) tlsContext).getAutoSniSanValidation());
82+
certificateValidationContext,
83+
((UpstreamTlsContext) tlsContext).getAutoSniSanValidation());
8184
sslContextBuilder = sslContextBuilder.trustManager(trustManagerFactory);
8285
} else {
8386
trustManagerFactory = new XdsTrustManagerFactory(
8487
savedTrustedRoots.toArray(new X509Certificate[0]),
85-
certificateValidationContext, ((UpstreamTlsContext) tlsContext).getAutoSniSanValidation());
88+
certificateValidationContext,
89+
((UpstreamTlsContext) tlsContext).getAutoSniSanValidation());
8690
sslContextBuilder = sslContextBuilder.trustManager(trustManagerFactory);
8791
}
8892
if (isMtls()) {

xds/src/main/java/io/grpc/xds/internal/security/certprovider/CertProviderServerSslContextProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class CertProviderServerSslContextProvider extends CertProviderSslContextP
5858

5959
@Override
6060
protected final AbstractMap.SimpleImmutableEntry<SslContextBuilder, TrustManager>
61-
getSslContextBuilderAndTrustManager(
61+
getSslContextBuilderAndTrustManager(
6262
CertificateValidationContext certificateValidationContextdationContext)
6363
throws CertStoreException, CertificateException, IOException {
6464
SslContextBuilder sslContextBuilder = SslContextBuilder.forServer(savedKey, savedCertChain);

xds/src/main/java/io/grpc/xds/internal/security/trust/XdsX509TrustManager.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,25 @@ void verifySubjectAltNameInChain(X509Certificate[] peerCertChain,
233233
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket)
234234
throws CertificateException {
235235
chooseDelegate(chain).checkClientTrusted(chain, authType, socket);
236-
verifySubjectAltNameInChain(chain, new ArrayList<>());
236+
verifySubjectAltNameInChain(chain, certContext != null
237+
? certContext.getMatchSubjectAltNamesList() : new ArrayList<>());
237238
}
238239

239240
@Override
240241
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine)
241242
throws CertificateException {
242243
chooseDelegate(chain).checkClientTrusted(chain, authType, sslEngine);
243-
verifySubjectAltNameInChain(chain, new ArrayList<>());
244+
verifySubjectAltNameInChain(chain, certContext != null
245+
? certContext.getMatchSubjectAltNamesList() : new ArrayList<>());
244246
}
245247

246248
@Override
249+
@SuppressWarnings("deprecation") // gRFC A29 predates match_typed_subject_alt_names
247250
public void checkClientTrusted(X509Certificate[] chain, String authType)
248251
throws CertificateException {
249252
chooseDelegate(chain).checkClientTrusted(chain, authType);
250-
verifySubjectAltNameInChain(chain, new ArrayList<>());
253+
verifySubjectAltNameInChain(chain, certContext != null
254+
? certContext.getMatchSubjectAltNamesList() : new ArrayList<>());
251255
}
252256

253257
@Override
@@ -264,7 +268,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType, Socket
264268
}
265269
sniMatchers = getAutoSniSanMatchers(sslParams);
266270
}
267-
if (sniMatchers.isEmpty()) {
271+
if (sniMatchers.isEmpty() && certContext != null) {
268272
sniMatchers = certContext.getMatchSubjectAltNamesList();
269273
}
270274
chooseDelegate(chain).checkServerTrusted(chain, authType, socket);
@@ -282,18 +286,20 @@ public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngi
282286
sslEngine.setSSLParameters(sslParams);
283287
sniMatchers = getAutoSniSanMatchers(sslParams);
284288
}
285-
if (sniMatchers.isEmpty()) {
289+
if (sniMatchers.isEmpty() && certContext != null) {
286290
sniMatchers = certContext.getMatchSubjectAltNamesList();
287291
}
288292
chooseDelegate(chain).checkServerTrusted(chain, authType, sslEngine);
289293
verifySubjectAltNameInChain(chain, sniMatchers);
290294
}
291295

292296
@Override
297+
@SuppressWarnings("deprecation") // gRFC A29 predates match_typed_subject_alt_names
293298
public void checkServerTrusted(X509Certificate[] chain, String authType)
294299
throws CertificateException {
295300
chooseDelegate(chain).checkServerTrusted(chain, authType);
296-
verifySubjectAltNameInChain(chain, new ArrayList<>());
301+
verifySubjectAltNameInChain(chain, certContext != null
302+
? certContext.getMatchSubjectAltNamesList() : new ArrayList<>());
297303
}
298304

299305
private List<StringMatcher> getAutoSniSanMatchers(SSLParameters sslParams) {
@@ -312,6 +318,7 @@ private List<StringMatcher> getAutoSniSanMatchers(SSLParameters sslParams) {
312318
}
313319
return sniNamesToMatch;
314320
}
321+
315322
private X509ExtendedTrustManager chooseDelegate(X509Certificate[] chain)
316323
throws CertificateException {
317324
if (spiffeTrustMapDelegates != null) {

0 commit comments

Comments
 (0)