mirror of https://github.com/grpc/grpc-java.git
xds: rename Sds to Security or Xds in various classes to eliminate references to SDS (#9529)
This commit is contained in:
parent
95b9d6db29
commit
074e919304
|
|
@ -20,7 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static io.grpc.xds.InternalXdsAttributes.ATTR_DRAIN_GRACE_NANOS;
|
import static io.grpc.xds.InternalXdsAttributes.ATTR_DRAIN_GRACE_NANOS;
|
||||||
import static io.grpc.xds.InternalXdsAttributes.ATTR_FILTER_CHAIN_SELECTOR_MANAGER;
|
import static io.grpc.xds.InternalXdsAttributes.ATTR_FILTER_CHAIN_SELECTOR_MANAGER;
|
||||||
import static io.grpc.xds.XdsServerWrapper.ATTR_SERVER_ROUTING_CONFIG;
|
import static io.grpc.xds.XdsServerWrapper.ATTR_SERVER_ROUTING_CONFIG;
|
||||||
import static io.grpc.xds.internal.sds.SdsProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
import static io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import io.grpc.ChannelCredentials;
|
||||||
import io.grpc.ExperimentalApi;
|
import io.grpc.ExperimentalApi;
|
||||||
import io.grpc.netty.InternalNettyChannelCredentials;
|
import io.grpc.netty.InternalNettyChannelCredentials;
|
||||||
import io.grpc.netty.InternalProtocolNegotiator;
|
import io.grpc.netty.InternalProtocolNegotiator;
|
||||||
import io.grpc.xds.internal.sds.SdsProtocolNegotiators;
|
import io.grpc.xds.internal.sds.SecurityProtocolNegotiators;
|
||||||
|
|
||||||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7514")
|
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7514")
|
||||||
public class XdsChannelCredentials {
|
public class XdsChannelCredentials {
|
||||||
|
|
@ -40,6 +40,6 @@ public class XdsChannelCredentials {
|
||||||
InternalProtocolNegotiator.ClientFactory fallbackNegotiator =
|
InternalProtocolNegotiator.ClientFactory fallbackNegotiator =
|
||||||
InternalNettyChannelCredentials.toNegotiator(checkNotNull(fallback, "fallback"));
|
InternalNettyChannelCredentials.toNegotiator(checkNotNull(fallback, "fallback"));
|
||||||
return InternalNettyChannelCredentials.create(
|
return InternalNettyChannelCredentials.create(
|
||||||
SdsProtocolNegotiators.clientProtocolNegotiatorFactory(fallbackNegotiator));
|
SecurityProtocolNegotiators.clientProtocolNegotiatorFactory(fallbackNegotiator));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import io.grpc.ExperimentalApi;
|
||||||
import io.grpc.ServerCredentials;
|
import io.grpc.ServerCredentials;
|
||||||
import io.grpc.netty.InternalNettyServerCredentials;
|
import io.grpc.netty.InternalNettyServerCredentials;
|
||||||
import io.grpc.netty.InternalProtocolNegotiator;
|
import io.grpc.netty.InternalProtocolNegotiator;
|
||||||
import io.grpc.xds.internal.sds.SdsProtocolNegotiators;
|
import io.grpc.xds.internal.sds.SecurityProtocolNegotiators;
|
||||||
|
|
||||||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7514")
|
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7514")
|
||||||
public class XdsServerCredentials {
|
public class XdsServerCredentials {
|
||||||
|
|
@ -40,6 +40,6 @@ public class XdsServerCredentials {
|
||||||
InternalProtocolNegotiator.ServerFactory fallbackNegotiator =
|
InternalProtocolNegotiator.ServerFactory fallbackNegotiator =
|
||||||
InternalNettyServerCredentials.toNegotiator(checkNotNull(fallback, "fallback"));
|
InternalNettyServerCredentials.toNegotiator(checkNotNull(fallback, "fallback"));
|
||||||
return InternalNettyServerCredentials.create(
|
return InternalNettyServerCredentials.create(
|
||||||
SdsProtocolNegotiators.serverProtocolNegotiatorFactory(fallbackNegotiator));
|
SecurityProtocolNegotiators.serverProtocolNegotiatorFactory(fallbackNegotiator));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import io.grpc.Internal;
|
||||||
import io.grpc.netty.GrpcSslContexts;
|
import io.grpc.netty.GrpcSslContexts;
|
||||||
import io.grpc.xds.Bootstrapper.CertificateProviderInfo;
|
import io.grpc.xds.Bootstrapper.CertificateProviderInfo;
|
||||||
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
|
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
|
||||||
import io.grpc.xds.internal.sds.trust.SdsTrustManagerFactory;
|
import io.grpc.xds.internal.sds.trust.XdsTrustManagerFactory;
|
||||||
import io.netty.handler.ssl.SslContextBuilder;
|
import io.netty.handler.ssl.SslContextBuilder;
|
||||||
import java.security.cert.CertStoreException;
|
import java.security.cert.CertStoreException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
@ -62,7 +62,7 @@ public final class CertProviderClientSslContextProvider extends CertProviderSslC
|
||||||
SslContextBuilder sslContextBuilder =
|
SslContextBuilder sslContextBuilder =
|
||||||
GrpcSslContexts.forClient()
|
GrpcSslContexts.forClient()
|
||||||
.trustManager(
|
.trustManager(
|
||||||
new SdsTrustManagerFactory(
|
new XdsTrustManagerFactory(
|
||||||
savedTrustedRoots.toArray(new X509Certificate[0]),
|
savedTrustedRoots.toArray(new X509Certificate[0]),
|
||||||
certificateValidationContextdationContext));
|
certificateValidationContextdationContext));
|
||||||
if (isMtls()) {
|
if (isMtls()) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import io.grpc.Internal;
|
||||||
import io.grpc.netty.GrpcSslContexts;
|
import io.grpc.netty.GrpcSslContexts;
|
||||||
import io.grpc.xds.Bootstrapper.CertificateProviderInfo;
|
import io.grpc.xds.Bootstrapper.CertificateProviderInfo;
|
||||||
import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext;
|
import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext;
|
||||||
import io.grpc.xds.internal.sds.trust.SdsTrustManagerFactory;
|
import io.grpc.xds.internal.sds.trust.XdsTrustManagerFactory;
|
||||||
import io.netty.handler.ssl.SslContextBuilder;
|
import io.netty.handler.ssl.SslContextBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -66,7 +66,7 @@ public final class CertProviderServerSslContextProvider extends CertProviderSslC
|
||||||
setClientAuthValues(
|
setClientAuthValues(
|
||||||
sslContextBuilder,
|
sslContextBuilder,
|
||||||
isMtls()
|
isMtls()
|
||||||
? new SdsTrustManagerFactory(
|
? new XdsTrustManagerFactory(
|
||||||
savedTrustedRoots.toArray(new X509Certificate[0]),
|
savedTrustedRoots.toArray(new X509Certificate[0]),
|
||||||
certificateValidationContextdationContext)
|
certificateValidationContextdationContext)
|
||||||
: null);
|
: null);
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,14 @@ import javax.annotation.Nullable;
|
||||||
* context.
|
* context.
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public final class SdsProtocolNegotiators {
|
public final class SecurityProtocolNegotiators {
|
||||||
|
|
||||||
// Prevent instantiation.
|
// Prevent instantiation.
|
||||||
private SdsProtocolNegotiators() {
|
private SecurityProtocolNegotiators() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(SdsProtocolNegotiators.class.getName());
|
private static final Logger logger
|
||||||
|
= Logger.getLogger(SecurityProtocolNegotiators.class.getName());
|
||||||
|
|
||||||
private static final AsciiString SCHEME = AsciiString.of("http");
|
private static final AsciiString SCHEME = AsciiString.of("http");
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext;
|
||||||
import io.grpc.xds.EnvoyServerProtoData.BaseTlsContext;
|
import io.grpc.xds.EnvoyServerProtoData.BaseTlsContext;
|
||||||
import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext;
|
import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext;
|
||||||
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
|
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
|
||||||
import io.grpc.xds.internal.sds.trust.SdsTrustManagerFactory;
|
import io.grpc.xds.internal.sds.trust.XdsTrustManagerFactory;
|
||||||
import io.netty.handler.ssl.ClientAuth;
|
import io.netty.handler.ssl.ClientAuth;
|
||||||
import io.netty.handler.ssl.SslContext;
|
import io.netty.handler.ssl.SslContext;
|
||||||
import io.netty.handler.ssl.SslContextBuilder;
|
import io.netty.handler.ssl.SslContextBuilder;
|
||||||
|
|
@ -70,11 +70,11 @@ public abstract class SslContextProvider implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setClientAuthValues(
|
protected void setClientAuthValues(
|
||||||
SslContextBuilder sslContextBuilder, SdsTrustManagerFactory sdsTrustManagerFactory)
|
SslContextBuilder sslContextBuilder, XdsTrustManagerFactory xdsTrustManagerFactory)
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
DownstreamTlsContext downstreamTlsContext = getDownstreamTlsContext();
|
DownstreamTlsContext downstreamTlsContext = getDownstreamTlsContext();
|
||||||
if (sdsTrustManagerFactory != null) {
|
if (xdsTrustManagerFactory != null) {
|
||||||
sslContextBuilder.trustManager(sdsTrustManagerFactory);
|
sslContextBuilder.trustManager(xdsTrustManagerFactory);
|
||||||
sslContextBuilder.clientAuth(
|
sslContextBuilder.clientAuth(
|
||||||
downstreamTlsContext.isRequireClientCertificate()
|
downstreamTlsContext.isRequireClientCertificate()
|
||||||
? ClientAuth.REQUIRE
|
? ClientAuth.REQUIRE
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables Client or server side to initialize this object with the received {@link BaseTlsContext}
|
* Enables Client or server side to initialize this object with the received {@link BaseTlsContext}
|
||||||
* and communicate it to the consumer i.e. {@link SdsProtocolNegotiators}
|
* and communicate it to the consumer i.e. {@link SecurityProtocolNegotiators}
|
||||||
* to lazily evaluate the {@link SslContextProvider}. The supplier prevents credentials leakage in
|
* to lazily evaluate the {@link SslContextProvider}. The supplier prevents credentials leakage in
|
||||||
* cases where the user is not using xDS credentials but the client/server contains a non-default
|
* cases where the user is not using xDS credentials but the client/server contains a non-default
|
||||||
* {@link BaseTlsContext}.
|
* {@link BaseTlsContext}.
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,15 @@ import javax.net.ssl.X509ExtendedTrustManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class used by providers of {@link TlsContextManagerImpl} to provide a
|
* Factory class used by providers of {@link TlsContextManagerImpl} to provide a
|
||||||
* {@link SdsX509TrustManager} for trust and SAN checks.
|
* {@link XdsX509TrustManager} for trust and SAN checks.
|
||||||
*/
|
*/
|
||||||
public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
public final class XdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(SdsTrustManagerFactory.class.getName());
|
private static final Logger logger = Logger.getLogger(XdsTrustManagerFactory.class.getName());
|
||||||
private SdsX509TrustManager sdsX509TrustManager;
|
private XdsX509TrustManager xdsX509TrustManager;
|
||||||
|
|
||||||
/** Constructor constructs from a {@link CertificateValidationContext}. */
|
/** Constructor constructs from a {@link CertificateValidationContext}. */
|
||||||
public SdsTrustManagerFactory(CertificateValidationContext certificateValidationContext)
|
public XdsTrustManagerFactory(CertificateValidationContext certificateValidationContext)
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
this(
|
this(
|
||||||
getTrustedCaFromCertContext(certificateValidationContext),
|
getTrustedCaFromCertContext(certificateValidationContext),
|
||||||
|
|
@ -59,13 +59,13 @@ public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SdsTrustManagerFactory(
|
public XdsTrustManagerFactory(
|
||||||
X509Certificate[] certs, CertificateValidationContext staticCertificateValidationContext)
|
X509Certificate[] certs, CertificateValidationContext staticCertificateValidationContext)
|
||||||
throws CertStoreException {
|
throws CertStoreException {
|
||||||
this(certs, staticCertificateValidationContext, true);
|
this(certs, staticCertificateValidationContext, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SdsTrustManagerFactory(
|
private XdsTrustManagerFactory(
|
||||||
X509Certificate[] certs,
|
X509Certificate[] certs,
|
||||||
CertificateValidationContext certificateValidationContext,
|
CertificateValidationContext certificateValidationContext,
|
||||||
boolean validationContextIsStatic)
|
boolean validationContextIsStatic)
|
||||||
|
|
@ -75,7 +75,7 @@ public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
certificateValidationContext == null || !certificateValidationContext.hasTrustedCa(),
|
certificateValidationContext == null || !certificateValidationContext.hasTrustedCa(),
|
||||||
"only static certificateValidationContext expected");
|
"only static certificateValidationContext expected");
|
||||||
}
|
}
|
||||||
sdsX509TrustManager = createSdsX509TrustManager(certs, certificateValidationContext);
|
xdsX509TrustManager = createSdsX509TrustManager(certs, certificateValidationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static X509Certificate[] getTrustedCaFromCertContext(
|
private static X509Certificate[] getTrustedCaFromCertContext(
|
||||||
|
|
@ -100,7 +100,7 @@ public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static SdsX509TrustManager createSdsX509TrustManager(
|
static XdsX509TrustManager createSdsX509TrustManager(
|
||||||
X509Certificate[] certs, CertificateValidationContext certContext) throws CertStoreException {
|
X509Certificate[] certs, CertificateValidationContext certContext) throws CertStoreException {
|
||||||
TrustManagerFactory tmf = null;
|
TrustManagerFactory tmf = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -133,7 +133,7 @@ public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
if (myDelegate == null) {
|
if (myDelegate == null) {
|
||||||
throw new CertStoreException("Native X509 TrustManager not found.");
|
throw new CertStoreException("Native X509 TrustManager not found.");
|
||||||
}
|
}
|
||||||
return new SdsX509TrustManager(certContext, myDelegate);
|
return new XdsX509TrustManager(certContext, myDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -148,6 +148,6 @@ public final class SdsTrustManagerFactory extends SimpleTrustManagerFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TrustManager[] engineGetTrustManagers() {
|
protected TrustManager[] engineGetTrustManagers() {
|
||||||
return new TrustManager[] {sdsX509TrustManager};
|
return new TrustManager[] {xdsX509TrustManager};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ import javax.net.ssl.X509TrustManager;
|
||||||
* Extension of {@link X509ExtendedTrustManager} that implements verification of
|
* Extension of {@link X509ExtendedTrustManager} that implements verification of
|
||||||
* SANs (subject-alternate-names) against the list in CertificateValidationContext.
|
* SANs (subject-alternate-names) against the list in CertificateValidationContext.
|
||||||
*/
|
*/
|
||||||
final class SdsX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager {
|
final class XdsX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager {
|
||||||
|
|
||||||
// ref: io.grpc.okhttp.internal.OkHostnameVerifier and
|
// ref: io.grpc.okhttp.internal.OkHostnameVerifier and
|
||||||
// sun.security.x509.GeneralNameInterface
|
// sun.security.x509.GeneralNameInterface
|
||||||
|
|
@ -52,8 +52,8 @@ final class SdsX509TrustManager extends X509ExtendedTrustManager implements X509
|
||||||
private final X509ExtendedTrustManager delegate;
|
private final X509ExtendedTrustManager delegate;
|
||||||
private final CertificateValidationContext certContext;
|
private final CertificateValidationContext certContext;
|
||||||
|
|
||||||
SdsX509TrustManager(@Nullable CertificateValidationContext certContext,
|
XdsX509TrustManager(@Nullable CertificateValidationContext certContext,
|
||||||
X509ExtendedTrustManager delegate) {
|
X509ExtendedTrustManager delegate) {
|
||||||
checkNotNull(delegate, "delegate");
|
checkNotNull(delegate, "delegate");
|
||||||
this.certContext = certContext;
|
this.certContext = certContext;
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
|
@ -18,7 +18,7 @@ package io.grpc.xds;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static io.grpc.xds.XdsServerWrapper.ATTR_SERVER_ROUTING_CONFIG;
|
import static io.grpc.xds.XdsServerWrapper.ATTR_SERVER_ROUTING_CONFIG;
|
||||||
import static io.grpc.xds.internal.sds.SdsProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
import static io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ package io.grpc.xds;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector.NO_FILTER_CHAIN;
|
import static io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector.NO_FILTER_CHAIN;
|
||||||
import static io.grpc.xds.internal.sds.SdsProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
import static io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.CLIENT_KEY_FILE
|
||||||
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.CLIENT_PEM_FILE;
|
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.CLIENT_PEM_FILE;
|
||||||
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.SERVER_1_KEY_FILE;
|
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.SERVER_1_KEY_FILE;
|
||||||
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.SERVER_1_PEM_FILE;
|
import static io.grpc.xds.internal.sds.CommonTlsContextTestsUtil.SERVER_1_PEM_FILE;
|
||||||
import static io.grpc.xds.internal.sds.SdsProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
import static io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ATTR_SERVER_SSL_CONTEXT_PROVIDER_SUPPLIER;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
@ -52,8 +52,8 @@ import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
|
||||||
import io.grpc.xds.InternalXdsAttributes;
|
import io.grpc.xds.InternalXdsAttributes;
|
||||||
import io.grpc.xds.TlsContextManager;
|
import io.grpc.xds.TlsContextManager;
|
||||||
import io.grpc.xds.internal.certprovider.CommonCertProviderTestUtils;
|
import io.grpc.xds.internal.certprovider.CommonCertProviderTestUtils;
|
||||||
import io.grpc.xds.internal.sds.SdsProtocolNegotiators.ClientSdsHandler;
|
import io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ClientSdsHandler;
|
||||||
import io.grpc.xds.internal.sds.SdsProtocolNegotiators.ClientSdsProtocolNegotiator;
|
import io.grpc.xds.internal.sds.SecurityProtocolNegotiators.ClientSdsProtocolNegotiator;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
|
|
@ -83,9 +83,9 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
/** Unit tests for {@link SdsProtocolNegotiators}. */
|
/** Unit tests for {@link SecurityProtocolNegotiators}. */
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class SdsProtocolNegotiatorsTest {
|
public class SecurityProtocolNegotiatorsTest {
|
||||||
|
|
||||||
private final GrpcHttp2ConnectionHandler grpcHandler =
|
private final GrpcHttp2ConnectionHandler grpcHandler =
|
||||||
FakeGrpcHttp2ConnectionHandler.newHandler();
|
FakeGrpcHttp2ConnectionHandler.newHandler();
|
||||||
|
|
@ -156,8 +156,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
SslContextProviderSupplier sslContextProviderSupplier =
|
SslContextProviderSupplier sslContextProviderSupplier =
|
||||||
new SslContextProviderSupplier(upstreamTlsContext,
|
new SslContextProviderSupplier(upstreamTlsContext,
|
||||||
new TlsContextManagerImpl(bootstrapInfoForClient));
|
new TlsContextManagerImpl(bootstrapInfoForClient));
|
||||||
SdsProtocolNegotiators.ClientSdsHandler clientSdsHandler =
|
SecurityProtocolNegotiators.ClientSdsHandler clientSdsHandler =
|
||||||
new SdsProtocolNegotiators.ClientSdsHandler(grpcHandler, sslContextProviderSupplier);
|
new SecurityProtocolNegotiators.ClientSdsHandler(grpcHandler, sslContextProviderSupplier);
|
||||||
pipeline.addLast(clientSdsHandler);
|
pipeline.addLast(clientSdsHandler);
|
||||||
channelHandlerCtx = pipeline.context(clientSdsHandler);
|
channelHandlerCtx = pipeline.context(clientSdsHandler);
|
||||||
assertNotNull(channelHandlerCtx); // clientSdsHandler ctx is non-null since we just added it
|
assertNotNull(channelHandlerCtx); // clientSdsHandler ctx is non-null since we just added it
|
||||||
|
|
@ -221,8 +221,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
"google_cloud_private_spiffe-server", true, true);
|
"google_cloud_private_spiffe-server", true, true);
|
||||||
|
|
||||||
TlsContextManagerImpl tlsContextManager = new TlsContextManagerImpl(bootstrapInfoForServer);
|
TlsContextManagerImpl tlsContextManager = new TlsContextManagerImpl(bootstrapInfoForServer);
|
||||||
SdsProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
SecurityProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
||||||
new SdsProtocolNegotiators.HandlerPickerHandler(grpcHandler,
|
new SecurityProtocolNegotiators.HandlerPickerHandler(grpcHandler,
|
||||||
InternalProtocolNegotiators.serverPlaintext());
|
InternalProtocolNegotiators.serverPlaintext());
|
||||||
pipeline.addLast(handlerPickerHandler);
|
pipeline.addLast(handlerPickerHandler);
|
||||||
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
||||||
|
|
@ -236,7 +236,7 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
pipeline.fireUserEventTriggered(InternalProtocolNegotiationEvent.withAttributes(event, attr));
|
pipeline.fireUserEventTriggered(InternalProtocolNegotiationEvent.withAttributes(event, attr));
|
||||||
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
||||||
assertThat(channelHandlerCtx).isNull();
|
assertThat(channelHandlerCtx).isNull();
|
||||||
channelHandlerCtx = pipeline.context(SdsProtocolNegotiators.ServerSdsHandler.class);
|
channelHandlerCtx = pipeline.context(SecurityProtocolNegotiators.ServerSdsHandler.class);
|
||||||
assertThat(channelHandlerCtx).isNotNull();
|
assertThat(channelHandlerCtx).isNotNull();
|
||||||
|
|
||||||
SslContextProviderSupplier sslContextProviderSupplier =
|
SslContextProviderSupplier sslContextProviderSupplier =
|
||||||
|
|
@ -259,7 +259,7 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
Object fromFuture = future.get(2, TimeUnit.SECONDS);
|
Object fromFuture = future.get(2, TimeUnit.SECONDS);
|
||||||
assertThat(fromFuture).isInstanceOf(SslContext.class);
|
assertThat(fromFuture).isInstanceOf(SslContext.class);
|
||||||
channel.runPendingTasks();
|
channel.runPendingTasks();
|
||||||
channelHandlerCtx = pipeline.context(SdsProtocolNegotiators.ServerSdsHandler.class);
|
channelHandlerCtx = pipeline.context(SecurityProtocolNegotiators.ServerSdsHandler.class);
|
||||||
assertThat(channelHandlerCtx).isNull();
|
assertThat(channelHandlerCtx).isNull();
|
||||||
|
|
||||||
// pipeline should only have SslHandler and ServerTlsHandler
|
// pipeline should only have SslHandler and ServerTlsHandler
|
||||||
|
|
@ -287,8 +287,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
};
|
};
|
||||||
pipeline = channel.pipeline();
|
pipeline = channel.pipeline();
|
||||||
|
|
||||||
SdsProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
SecurityProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
||||||
new SdsProtocolNegotiators.HandlerPickerHandler(
|
new SecurityProtocolNegotiators.HandlerPickerHandler(
|
||||||
grpcHandler, mockProtocolNegotiator);
|
grpcHandler, mockProtocolNegotiator);
|
||||||
pipeline.addLast(handlerPickerHandler);
|
pipeline.addLast(handlerPickerHandler);
|
||||||
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
||||||
|
|
@ -313,8 +313,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
ChannelHandler mockChannelHandler = mock(ChannelHandler.class);
|
ChannelHandler mockChannelHandler = mock(ChannelHandler.class);
|
||||||
ProtocolNegotiator mockProtocolNegotiator = mock(ProtocolNegotiator.class);
|
ProtocolNegotiator mockProtocolNegotiator = mock(ProtocolNegotiator.class);
|
||||||
when(mockProtocolNegotiator.newHandler(grpcHandler)).thenReturn(mockChannelHandler);
|
when(mockProtocolNegotiator.newHandler(grpcHandler)).thenReturn(mockChannelHandler);
|
||||||
SdsProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
SecurityProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
||||||
new SdsProtocolNegotiators.HandlerPickerHandler(
|
new SecurityProtocolNegotiators.HandlerPickerHandler(
|
||||||
grpcHandler, mockProtocolNegotiator);
|
grpcHandler, mockProtocolNegotiator);
|
||||||
pipeline.addLast(handlerPickerHandler);
|
pipeline.addLast(handlerPickerHandler);
|
||||||
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
||||||
|
|
@ -333,8 +333,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nullTlsContext_nullFallbackProtocolNegotiator_expectException() {
|
public void nullTlsContext_nullFallbackProtocolNegotiator_expectException() {
|
||||||
SdsProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
SecurityProtocolNegotiators.HandlerPickerHandler handlerPickerHandler =
|
||||||
new SdsProtocolNegotiators.HandlerPickerHandler(
|
new SecurityProtocolNegotiators.HandlerPickerHandler(
|
||||||
grpcHandler, null);
|
grpcHandler, null);
|
||||||
pipeline.addLast(handlerPickerHandler);
|
pipeline.addLast(handlerPickerHandler);
|
||||||
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
channelHandlerCtx = pipeline.context(handlerPickerHandler);
|
||||||
|
|
@ -368,8 +368,8 @@ public class SdsProtocolNegotiatorsTest {
|
||||||
SslContextProviderSupplier sslContextProviderSupplier =
|
SslContextProviderSupplier sslContextProviderSupplier =
|
||||||
new SslContextProviderSupplier(upstreamTlsContext,
|
new SslContextProviderSupplier(upstreamTlsContext,
|
||||||
new TlsContextManagerImpl(bootstrapInfoForClient));
|
new TlsContextManagerImpl(bootstrapInfoForClient));
|
||||||
SdsProtocolNegotiators.ClientSdsHandler clientSdsHandler =
|
SecurityProtocolNegotiators.ClientSdsHandler clientSdsHandler =
|
||||||
new SdsProtocolNegotiators.ClientSdsHandler(grpcHandler, sslContextProviderSupplier);
|
new SecurityProtocolNegotiators.ClientSdsHandler(grpcHandler, sslContextProviderSupplier);
|
||||||
|
|
||||||
pipeline.addLast(clientSdsHandler);
|
pipeline.addLast(clientSdsHandler);
|
||||||
channelHandlerCtx = pipeline.context(clientSdsHandler);
|
channelHandlerCtx = pipeline.context(clientSdsHandler);
|
||||||
|
|
@ -38,22 +38,22 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
/** Unit tests for {@link SdsTrustManagerFactory}. */
|
/** Unit tests for {@link XdsTrustManagerFactory}. */
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class SdsTrustManagerFactoryTest {
|
public class XdsTrustManagerFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructor_fromFile() throws CertificateException, IOException, CertStoreException {
|
public void constructor_fromFile() throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
||||||
assertThat(factory).isNotNull();
|
assertThat(factory).isNotNull();
|
||||||
TrustManager[] tms = factory.getTrustManagers();
|
TrustManager[] tms = factory.getTrustManagers();
|
||||||
assertThat(tms).isNotNull();
|
assertThat(tms).isNotNull();
|
||||||
assertThat(tms).hasLength(1);
|
assertThat(tms).hasLength(1);
|
||||||
TrustManager myTm = tms[0];
|
TrustManager myTm = tms[0];
|
||||||
assertThat(myTm).isInstanceOf(SdsX509TrustManager.class);
|
assertThat(myTm).isInstanceOf(XdsX509TrustManager.class);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) myTm;
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) myTm;
|
||||||
X509Certificate[] acceptedIssuers = sdsX509TrustManager.getAcceptedIssuers();
|
X509Certificate[] acceptedIssuers = xdsX509TrustManager.getAcceptedIssuers();
|
||||||
assertThat(acceptedIssuers).isNotNull();
|
assertThat(acceptedIssuers).isNotNull();
|
||||||
assertThat(acceptedIssuers).hasLength(1);
|
assertThat(acceptedIssuers).hasLength(1);
|
||||||
X509Certificate caCert = acceptedIssuers[0];
|
X509Certificate caCert = acceptedIssuers[0];
|
||||||
|
|
@ -64,16 +64,16 @@ public class SdsTrustManagerFactoryTest {
|
||||||
@Test
|
@Test
|
||||||
public void constructor_fromInlineBytes()
|
public void constructor_fromInlineBytes()
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPathAsInlineBytes(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPathAsInlineBytes(CA_PEM_FILE));
|
||||||
assertThat(factory).isNotNull();
|
assertThat(factory).isNotNull();
|
||||||
TrustManager[] tms = factory.getTrustManagers();
|
TrustManager[] tms = factory.getTrustManagers();
|
||||||
assertThat(tms).isNotNull();
|
assertThat(tms).isNotNull();
|
||||||
assertThat(tms).hasLength(1);
|
assertThat(tms).hasLength(1);
|
||||||
TrustManager myTm = tms[0];
|
TrustManager myTm = tms[0];
|
||||||
assertThat(myTm).isInstanceOf(SdsX509TrustManager.class);
|
assertThat(myTm).isInstanceOf(XdsX509TrustManager.class);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) myTm;
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) myTm;
|
||||||
X509Certificate[] acceptedIssuers = sdsX509TrustManager.getAcceptedIssuers();
|
X509Certificate[] acceptedIssuers = xdsX509TrustManager.getAcceptedIssuers();
|
||||||
assertThat(acceptedIssuers).isNotNull();
|
assertThat(acceptedIssuers).isNotNull();
|
||||||
assertThat(acceptedIssuers).hasLength(1);
|
assertThat(acceptedIssuers).hasLength(1);
|
||||||
X509Certificate caCert = acceptedIssuers[0];
|
X509Certificate caCert = acceptedIssuers[0];
|
||||||
|
|
@ -87,16 +87,16 @@ public class SdsTrustManagerFactoryTest {
|
||||||
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
||||||
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
||||||
"san2");
|
"san2");
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
new XdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
||||||
assertThat(factory).isNotNull();
|
assertThat(factory).isNotNull();
|
||||||
TrustManager[] tms = factory.getTrustManagers();
|
TrustManager[] tms = factory.getTrustManagers();
|
||||||
assertThat(tms).isNotNull();
|
assertThat(tms).isNotNull();
|
||||||
assertThat(tms).hasLength(1);
|
assertThat(tms).hasLength(1);
|
||||||
TrustManager myTm = tms[0];
|
TrustManager myTm = tms[0];
|
||||||
assertThat(myTm).isInstanceOf(SdsX509TrustManager.class);
|
assertThat(myTm).isInstanceOf(XdsX509TrustManager.class);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) myTm;
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) myTm;
|
||||||
X509Certificate[] acceptedIssuers = sdsX509TrustManager.getAcceptedIssuers();
|
X509Certificate[] acceptedIssuers = xdsX509TrustManager.getAcceptedIssuers();
|
||||||
assertThat(acceptedIssuers).isNotNull();
|
assertThat(acceptedIssuers).isNotNull();
|
||||||
assertThat(acceptedIssuers).hasLength(1);
|
assertThat(acceptedIssuers).hasLength(1);
|
||||||
X509Certificate caCert = acceptedIssuers[0];
|
X509Certificate caCert = acceptedIssuers[0];
|
||||||
|
|
@ -110,12 +110,12 @@ public class SdsTrustManagerFactoryTest {
|
||||||
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
||||||
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
||||||
"waterzooi.test.google.be");
|
"waterzooi.test.google.be");
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
new XdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] serverChain =
|
X509Certificate[] serverChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
sdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
xdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -123,7 +123,7 @@ public class SdsTrustManagerFactoryTest {
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
||||||
try {
|
try {
|
||||||
new SdsTrustManagerFactory(
|
new XdsTrustManagerFactory(
|
||||||
new X509Certificate[] {x509Cert}, getCertContextFromPath(CA_PEM_FILE));
|
new X509Certificate[] {x509Cert}, getCertContextFromPath(CA_PEM_FILE));
|
||||||
Assert.fail("no exception thrown");
|
Assert.fail("no exception thrown");
|
||||||
} catch (IllegalArgumentException expected) {
|
} catch (IllegalArgumentException expected) {
|
||||||
|
|
@ -139,13 +139,13 @@ public class SdsTrustManagerFactoryTest {
|
||||||
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
||||||
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
||||||
"san2");
|
"san2");
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
new XdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] serverChain =
|
X509Certificate[] serverChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
sdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
xdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
||||||
Assert.fail("no exception thrown");
|
Assert.fail("no exception thrown");
|
||||||
} catch (CertificateException expected) {
|
} catch (CertificateException expected) {
|
||||||
assertThat(expected)
|
assertThat(expected)
|
||||||
|
|
@ -160,13 +160,13 @@ public class SdsTrustManagerFactoryTest {
|
||||||
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
X509Certificate x509Cert = TestUtils.loadX509Cert(CA_PEM_FILE);
|
||||||
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
CertificateValidationContext staticValidationContext = buildStaticValidationContext("san1",
|
||||||
"san2");
|
"san2");
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
new XdsTrustManagerFactory(new X509Certificate[]{x509Cert}, staticValidationContext);
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] clientChain =
|
X509Certificate[] clientChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
sdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
xdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
||||||
Assert.fail("no exception thrown");
|
Assert.fail("no exception thrown");
|
||||||
} catch (CertificateException expected) {
|
} catch (CertificateException expected) {
|
||||||
assertThat(expected)
|
assertThat(expected)
|
||||||
|
|
@ -178,35 +178,35 @@ public class SdsTrustManagerFactoryTest {
|
||||||
@Test
|
@Test
|
||||||
public void checkServerTrusted_goodCert()
|
public void checkServerTrusted_goodCert()
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] serverChain =
|
X509Certificate[] serverChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
sdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
xdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkClientTrusted_goodCert()
|
public void checkClientTrusted_goodCert()
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] clientChain =
|
X509Certificate[] clientChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(CLIENT_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(CLIENT_PEM_FILE));
|
||||||
sdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
xdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkServerTrusted_badCert_throwsException()
|
public void checkServerTrusted_badCert_throwsException()
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] serverChain =
|
X509Certificate[] serverChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(BAD_SERVER_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(BAD_SERVER_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
sdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
xdsX509TrustManager.checkServerTrusted(serverChain, "RSA");
|
||||||
Assert.fail("no exception thrown");
|
Assert.fail("no exception thrown");
|
||||||
} catch (CertificateException expected) {
|
} catch (CertificateException expected) {
|
||||||
assertThat(expected)
|
assertThat(expected)
|
||||||
|
|
@ -218,13 +218,13 @@ public class SdsTrustManagerFactoryTest {
|
||||||
@Test
|
@Test
|
||||||
public void checkClientTrusted_badCert_throwsException()
|
public void checkClientTrusted_badCert_throwsException()
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
SdsTrustManagerFactory factory =
|
XdsTrustManagerFactory factory =
|
||||||
new SdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
new XdsTrustManagerFactory(getCertContextFromPath(CA_PEM_FILE));
|
||||||
SdsX509TrustManager sdsX509TrustManager = (SdsX509TrustManager) factory.getTrustManagers()[0];
|
XdsX509TrustManager xdsX509TrustManager = (XdsX509TrustManager) factory.getTrustManagers()[0];
|
||||||
X509Certificate[] clientChain =
|
X509Certificate[] clientChain =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(BAD_CLIENT_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(BAD_CLIENT_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
sdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
xdsX509TrustManager.checkClientTrusted(clientChain, "RSA");
|
||||||
Assert.fail("no exception thrown");
|
Assert.fail("no exception thrown");
|
||||||
} catch (CertificateException expected) {
|
} catch (CertificateException expected) {
|
||||||
assertThat(expected)
|
assertThat(expected)
|
||||||
|
|
@ -54,10 +54,10 @@ import org.mockito.junit.MockitoJUnit;
|
||||||
import org.mockito.junit.MockitoRule;
|
import org.mockito.junit.MockitoRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link SdsX509TrustManager}.
|
* Unit tests for {@link XdsX509TrustManager}.
|
||||||
*/
|
*/
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class SdsX509TrustManagerTest {
|
public class XdsX509TrustManagerTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mockitoRule = MockitoJUnit.rule();
|
||||||
|
|
@ -68,11 +68,11 @@ public class SdsX509TrustManagerTest {
|
||||||
@Mock
|
@Mock
|
||||||
private SSLSession mockSession;
|
private SSLSession mockSession;
|
||||||
|
|
||||||
private SdsX509TrustManager trustManager;
|
private XdsX509TrustManager trustManager;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nullCertContextTest() throws CertificateException, IOException {
|
public void nullCertContextTest() throws CertificateException, IOException {
|
||||||
trustManager = new SdsX509TrustManager(null, mockDelegate);
|
trustManager = new XdsX509TrustManager(null, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -81,7 +81,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@Test
|
@Test
|
||||||
public void emptySanListContextTest() throws CertificateException, IOException {
|
public void emptySanListContextTest() throws CertificateException, IOException {
|
||||||
CertificateValidationContext certContext = CertificateValidationContext.getDefaultInstance();
|
CertificateValidationContext certContext = CertificateValidationContext.getDefaultInstance();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -93,7 +93,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
try {
|
try {
|
||||||
trustManager.verifySubjectAltNameInChain(null);
|
trustManager.verifySubjectAltNameInChain(null);
|
||||||
fail("no exception thrown");
|
fail("no exception thrown");
|
||||||
|
|
@ -108,7 +108,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
try {
|
try {
|
||||||
trustManager.verifySubjectAltNameInChain(new X509Certificate[0]);
|
trustManager.verifySubjectAltNameInChain(new X509Certificate[0]);
|
||||||
fail("no exception thrown");
|
fail("no exception thrown");
|
||||||
|
|
@ -123,7 +123,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(CLIENT_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(CLIENT_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -144,7 +144,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -161,7 +161,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -179,7 +179,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -195,7 +195,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -209,7 +209,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -230,7 +230,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -243,7 +243,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -257,7 +257,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -275,7 +275,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -288,7 +288,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -302,7 +302,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -320,7 +320,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -336,7 +336,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -352,7 +352,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -368,7 +368,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -384,7 +384,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -407,7 +407,7 @@ public class SdsX509TrustManagerTest {
|
||||||
.addMatchSubjectAltNames(stringMatcher)
|
.addMatchSubjectAltNames(stringMatcher)
|
||||||
.addMatchSubjectAltNames(stringMatcher1)
|
.addMatchSubjectAltNames(stringMatcher1)
|
||||||
.build();
|
.build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -420,7 +420,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -443,7 +443,7 @@ public class SdsX509TrustManagerTest {
|
||||||
.addMatchSubjectAltNames(stringMatcher)
|
.addMatchSubjectAltNames(stringMatcher)
|
||||||
.addMatchSubjectAltNames(stringMatcher1) // should match suffix test.youTube.Com
|
.addMatchSubjectAltNames(stringMatcher1) // should match suffix test.youTube.Com
|
||||||
.build();
|
.build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -461,7 +461,7 @@ public class SdsX509TrustManagerTest {
|
||||||
.addMatchSubjectAltNames(stringMatcher)
|
.addMatchSubjectAltNames(stringMatcher)
|
||||||
.addMatchSubjectAltNames(stringMatcher1) // should contain est.Google.f
|
.addMatchSubjectAltNames(stringMatcher1) // should contain est.Google.f
|
||||||
.build();
|
.build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -478,7 +478,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -499,7 +499,7 @@ public class SdsX509TrustManagerTest {
|
||||||
.addMatchSubjectAltNames(stringMatcher)
|
.addMatchSubjectAltNames(stringMatcher)
|
||||||
.addMatchSubjectAltNames(stringMatcher1)
|
.addMatchSubjectAltNames(stringMatcher1)
|
||||||
.build();
|
.build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
trustManager.verifySubjectAltNameInChain(certs);
|
trustManager.verifySubjectAltNameInChain(certs);
|
||||||
|
|
@ -515,7 +515,7 @@ public class SdsX509TrustManagerTest {
|
||||||
.addMatchSubjectAltNames(stringMatcher)
|
.addMatchSubjectAltNames(stringMatcher)
|
||||||
.addMatchSubjectAltNames(stringMatcher1)
|
.addMatchSubjectAltNames(stringMatcher1)
|
||||||
.build();
|
.build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate[] certs =
|
X509Certificate[] certs =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
|
||||||
try {
|
try {
|
||||||
|
|
@ -590,7 +590,7 @@ public class SdsX509TrustManagerTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
CertificateValidationContext certContext =
|
CertificateValidationContext certContext =
|
||||||
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
|
||||||
trustManager = new SdsX509TrustManager(certContext, mockDelegate);
|
trustManager = new XdsX509TrustManager(certContext, mockDelegate);
|
||||||
X509Certificate mockCert = mock(X509Certificate.class);
|
X509Certificate mockCert = mock(X509Certificate.class);
|
||||||
|
|
||||||
when(mockCert.getSubjectAlternativeNames())
|
when(mockCert.getSubjectAlternativeNames())
|
||||||
|
|
@ -629,7 +629,7 @@ public class SdsX509TrustManagerTest {
|
||||||
throws CertificateException, IOException, CertStoreException {
|
throws CertificateException, IOException, CertStoreException {
|
||||||
X509Certificate[] caCerts =
|
X509Certificate[] caCerts =
|
||||||
CertificateUtils.toX509Certificates(TestUtils.loadCert(CA_PEM_FILE));
|
CertificateUtils.toX509Certificates(TestUtils.loadCert(CA_PEM_FILE));
|
||||||
trustManager = SdsTrustManagerFactory.createSdsX509TrustManager(caCerts,
|
trustManager = XdsTrustManagerFactory.createSdsX509TrustManager(caCerts,
|
||||||
null);
|
null);
|
||||||
when(mockSession.getProtocol()).thenReturn("TLSv1.2");
|
when(mockSession.getProtocol()).thenReturn("TLSv1.2");
|
||||||
when(mockSession.getPeerHost()).thenReturn("peer-host-from-mock");
|
when(mockSession.getPeerHost()).thenReturn("peer-host-from-mock");
|
||||||
Loading…
Reference in New Issue