Search in sources :

Example 6 with DownstreamTlsContext

use of io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext in project grpc-java by grpc.

the class ServerSslContextProviderFactoryTest method bothPresent_expectCertProviderServerSslContextProvider.

@Test
public void bothPresent_expectCertProviderServerSslContextProvider() throws XdsInitializationException {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    DownstreamTlsContext downstreamTlsContext = CommonTlsContextTestsUtil.buildDownstreamTlsContextForCertProviderInstance("gcp_id", "cert-default", "gcp_id", "root-default", /* alpnProtocols= */
    null, /* staticCertValidationContext= */
    null, /* requireClientCert= */
    true);
    CommonTlsContext.Builder builder = downstreamTlsContext.getCommonTlsContext().toBuilder();
    builder = ClientSslContextProviderFactoryTest.addFilenames(builder, "foo.pem", "foo.key", "root.pem");
    downstreamTlsContext = new EnvoyServerProtoData.DownstreamTlsContext(builder.build(), downstreamTlsContext.isRequireClientCertificate());
    Bootstrapper.BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils.getTestBootstrapInfo();
    serverSslContextProviderFactory = new ServerSslContextProviderFactory(bootstrapInfo, certProviderServerSslContextProviderFactory);
    SslContextProvider sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
    verifyWatcher(sslContextProvider, watcherCaptor[0]);
}
Also used : Bootstrapper(io.grpc.xds.Bootstrapper) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) CertProviderServerSslContextProvider(io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider) CommonTlsContext(io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext) EnvoyServerProtoData(io.grpc.xds.EnvoyServerProtoData) Test(org.junit.Test)

Example 7 with DownstreamTlsContext

use of io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext in project grpc-java by grpc.

the class ServerSslContextProviderFactoryTest method createCertProviderServerSslContextProvider_withStaticContext.

@Test
public void createCertProviderServerSslContextProvider_withStaticContext() throws XdsInitializationException {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    CertificateValidationContext staticCertValidationContext = CertificateValidationContext.newBuilder().addAllMatchSubjectAltNames(ImmutableSet.of(StringMatcher.newBuilder().setExact("foo").build(), StringMatcher.newBuilder().setExact("bar").build())).build();
    DownstreamTlsContext downstreamTlsContext = CommonTlsContextTestsUtil.buildDownstreamTlsContextForCertProviderInstance("gcp_id", "cert-default", "gcp_id", "root-default", /* alpnProtocols= */
    null, staticCertValidationContext, /* requireClientCert= */
    true);
    Bootstrapper.BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils.getTestBootstrapInfo();
    serverSslContextProviderFactory = new ServerSslContextProviderFactory(bootstrapInfo, certProviderServerSslContextProviderFactory);
    SslContextProvider sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
    verifyWatcher(sslContextProvider, watcherCaptor[0]);
}
Also used : Bootstrapper(io.grpc.xds.Bootstrapper) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) CertProviderServerSslContextProvider(io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider) CertificateValidationContext(io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext) Test(org.junit.Test)

Example 8 with DownstreamTlsContext

use of io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext in project grpc-java by grpc.

the class ServerSslContextProviderFactoryTest method createCertProviderServerSslContextProvider.

@Test
public void createCertProviderServerSslContextProvider() throws XdsInitializationException {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    DownstreamTlsContext downstreamTlsContext = CommonTlsContextTestsUtil.buildDownstreamTlsContextForCertProviderInstance("gcp_id", "cert-default", "gcp_id", "root-default", /* alpnProtocols= */
    null, /* staticCertValidationContext= */
    null, /* requireClientCert= */
    true);
    Bootstrapper.BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils.getTestBootstrapInfo();
    serverSslContextProviderFactory = new ServerSslContextProviderFactory(bootstrapInfo, certProviderServerSslContextProviderFactory);
    SslContextProvider sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
    verifyWatcher(sslContextProvider, watcherCaptor[0]);
    // verify that bootstrapInfo is cached...
    sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
}
Also used : Bootstrapper(io.grpc.xds.Bootstrapper) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) CertProviderServerSslContextProvider(io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider) Test(org.junit.Test)

Example 9 with DownstreamTlsContext

use of io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext in project grpc-java by grpc.

the class ServerSslContextProviderFactoryTest method createCertProviderServerSslContextProvider_onlyCertInstance.

@Test
public void createCertProviderServerSslContextProvider_onlyCertInstance() throws XdsInitializationException {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    DownstreamTlsContext downstreamTlsContext = CommonTlsContextTestsUtil.buildDownstreamTlsContextForCertProviderInstance("gcp_id", "cert-default", /* rootInstanceName= */
    null, /* rootCertName= */
    null, /* alpnProtocols= */
    null, /* staticCertValidationContext= */
    null, /* requireClientCert= */
    true);
    Bootstrapper.BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils.getTestBootstrapInfo();
    serverSslContextProviderFactory = new ServerSslContextProviderFactory(bootstrapInfo, certProviderServerSslContextProviderFactory);
    SslContextProvider sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
    verifyWatcher(sslContextProvider, watcherCaptor[0]);
}
Also used : Bootstrapper(io.grpc.xds.Bootstrapper) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) CertProviderServerSslContextProvider(io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider) Test(org.junit.Test)

Example 10 with DownstreamTlsContext

use of io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext in project grpc-java by grpc.

the class ServerSslContextProviderFactoryTest method createCertProviderServerSslContextProvider_2providers.

@Test
public void createCertProviderServerSslContextProvider_2providers() throws XdsInitializationException {
    final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[2];
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
    createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "file_watcher", 1);
    DownstreamTlsContext downstreamTlsContext = CommonTlsContextTestsUtil.buildDownstreamTlsContextForCertProviderInstance("gcp_id", "cert-default", "file_provider", "root-default", /* alpnProtocols= */
    null, /* staticCertValidationContext= */
    null, /* requireClientCert= */
    true);
    Bootstrapper.BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils.getTestBootstrapInfo();
    serverSslContextProviderFactory = new ServerSslContextProviderFactory(bootstrapInfo, certProviderServerSslContextProviderFactory);
    SslContextProvider sslContextProvider = serverSslContextProviderFactory.create(downstreamTlsContext);
    assertThat(sslContextProvider).isInstanceOf(CertProviderServerSslContextProvider.class);
    verifyWatcher(sslContextProvider, watcherCaptor[0]);
    verifyWatcher(sslContextProvider, watcherCaptor[1]);
}
Also used : Bootstrapper(io.grpc.xds.Bootstrapper) DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) CertProviderServerSslContextProvider(io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider) Test(org.junit.Test)

Aggregations

DownstreamTlsContext (io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext)18 Test (org.junit.Test)15 Bootstrapper (io.grpc.xds.Bootstrapper)9 SimpleServiceGrpc (io.grpc.testing.protobuf.SimpleServiceGrpc)6 CertProviderServerSslContextProvider (io.grpc.xds.internal.certprovider.CertProviderServerSslContextProvider)6 UpstreamTlsContext (io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext)4 StatusRuntimeException (io.grpc.StatusRuntimeException)3 CertificateValidationContext (io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext)2 CommonTlsContext (io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext)2 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)2 Attributes (io.grpc.Attributes)1 FakeClock (io.grpc.internal.FakeClock)1 InternalProtocolNegotiationEvent (io.grpc.netty.InternalProtocolNegotiationEvent)1 ProtocolNegotiationEvent (io.grpc.netty.ProtocolNegotiationEvent)1 EnvoyServerProtoData (io.grpc.xds.EnvoyServerProtoData)1 InternalXdsAttributes (io.grpc.xds.InternalXdsAttributes)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 SslContext (io.netty.handler.ssl.SslContext)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1