Search in sources :

Example 16 with DownstreamTlsContext

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

the class XdsSdsClientServerTest method tlsClientServer_noClientAuthentication.

/**
 * TLS channel - no mTLS.
 */
@Test
public void tlsClientServer_noClientAuthentication() throws Exception {
    DownstreamTlsContext downstreamTlsContext = setBootstrapInfoAndBuildDownstreamTlsContext(null, null, null, null, false, false);
    buildServerWithTlsContext(downstreamTlsContext);
    // for TLS, client only needs trustCa
    UpstreamTlsContext upstreamTlsContext = setBootstrapInfoAndBuildUpstreamTlsContext(CLIENT_KEY_FILE, CLIENT_PEM_FILE, false);
    SimpleServiceGrpc.SimpleServiceBlockingStub blockingStub = getBlockingStub(upstreamTlsContext, /* overrideAuthority= */
    OVERRIDE_AUTHORITY);
    assertThat(unaryRpc(/* requestMessage= */
    "buddy", blockingStub)).isEqualTo("Hello buddy");
}
Also used : DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) UpstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext) SimpleServiceGrpc(io.grpc.testing.protobuf.SimpleServiceGrpc) Test(org.junit.Test)

Example 17 with DownstreamTlsContext

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

the class XdsSdsClientServerTest method noClientAuth_sendBadClientCert_passes.

@Test
public void noClientAuth_sendBadClientCert_passes() throws Exception {
    DownstreamTlsContext downstreamTlsContext = setBootstrapInfoAndBuildDownstreamTlsContext(null, null, null, null, false, false);
    buildServerWithTlsContext(downstreamTlsContext);
    UpstreamTlsContext upstreamTlsContext = setBootstrapInfoAndBuildUpstreamTlsContext(BAD_CLIENT_KEY_FILE, BAD_CLIENT_PEM_FILE, true);
    SimpleServiceGrpc.SimpleServiceBlockingStub blockingStub = getBlockingStub(upstreamTlsContext, /* overrideAuthority= */
    OVERRIDE_AUTHORITY);
    assertThat(unaryRpc("buddy", blockingStub)).isEqualTo("Hello buddy");
}
Also used : DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) UpstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext) SimpleServiceGrpc(io.grpc.testing.protobuf.SimpleServiceGrpc) Test(org.junit.Test)

Example 18 with DownstreamTlsContext

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

the class XdsSdsClientServerTest method performMtlsTestAndGetListenerWatcher.

private void performMtlsTestAndGetListenerWatcher(UpstreamTlsContext upstreamTlsContext, String certInstanceName2, String privateKey2, String cert2, String trustCa2) throws Exception {
    DownstreamTlsContext downstreamTlsContext = setBootstrapInfoAndBuildDownstreamTlsContext(certInstanceName2, privateKey2, cert2, trustCa2, true, true);
    buildServerWithFallbackServerCredentials(InsecureServerCredentials.create(), downstreamTlsContext);
    SimpleServiceGrpc.SimpleServiceBlockingStub blockingStub = getBlockingStub(upstreamTlsContext, OVERRIDE_AUTHORITY);
    assertThat(unaryRpc("buddy", blockingStub)).isEqualTo("Hello buddy");
}
Also used : DownstreamTlsContext(io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext) SimpleServiceGrpc(io.grpc.testing.protobuf.SimpleServiceGrpc)

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