interop-test | ESM-CJS interop test | Mock library
kandi X-RAY | interop-test Summary
kandi X-RAY | interop-test Summary
ESM-CJS interop test
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of interop-test
interop-test Key Features
interop-test Examples and Code Snippets
Community Discussions
Trending Discussions on interop-test
QUESTION
I work on a software application that uses gRPC to establish a bi-directional stream between client and a server.
I'm looking for something similar to this ticket's answer only in java: How to enable server side SSL for gRPC?
I would like to configure my application so that they can choose what TLS scenario they want to use:
Scenario 1: plaintext (no encryption)
Scenario 2: Server-side TLS
Scenario 3: Mutual TLS
For TLS setups, I am using Java on non-Android environments, so I will only be considering the OpenSSL installed scenario using https://github.com/grpc/grpc-java/blob/master/SECURITY.md#openssl-statically-linked-netty-tcnative-boringssl-static
Configuring the server side seems pretty straight forward because it is documented quite well: https://github.com/grpc/grpc-java/blob/master/SECURITY.md#mutual-tls
Here would be the steps for the corresponding TLS options:
Sever-side configuration for Scenario 1: Use builder.usePlaintext
Sever-side configuration for Scenario 2: Add a NettyServerBuilder.sslContext
built by SSL Context Builder with GrpcSslContexts.forServer
and set the cert chain
and cert key
(and password if needed)
Sever-side configuration for Scenario 3: Add a NettyServerBuilder.sslContext
built by SSL Context Builder with GrpcSslContexts.forServer
and set the cert chain
and cert key
(and password if needed), and also set a trustManager
on the sslContextBuidler set to the trust cert file.
The server-side part is well documented which is excellent.
Now I want to configure a NettyChannelBuilder
on the client side. The only thing I can find information on this is in this unit test: https://github.com/grpc/grpc-java/blob/master/interop-testing/src/test/java/io/grpc/testing/integration/TlsTest.java
Here are the configurations I think are needed, but need to get confirmation on.
Client-side configuration for Scenario 1: Use nettyChannelBuilder.usePlaintext(true)
. This will disable TLS on the netty channel to grpc.
Client-side configuration for Scenario 2: Set the sslContext using nettyChannelBuilder.negotiationType(NegotiationType.TLS).sslContext(GrpcSslContexts.configure(SslContextBuilder.forClient(), SslProvider.OPENSSL).build())
. This will configure the channel to communicate through TLS to grpc server using the default ciphers and application protocol configs.
Client-side configuration for Scenario 3: Set up TLS for the netty channel using nettyChannelBuilder.negotiationType(NegotiationType.TLS).sslContext(GrpcSslContexts.configure(SslContextBuilder.forClient(), SslProvider.OPENSSL).sslContextBuilder.trustManager(clientAuthCertFile)
.clientAuth(ClientAuth.OPTIONAL).build())
where clientAuthCertFile
is the trust cert file and ClientAuth.OPTIONAL
can also be ClientAuth.REQUIRED
if you require mutual TLS.
Is there anything incorrect with my client-side configurations? Do I need any tweaks? I will add this as a PR to the security.md file after getting some blessing from the community on this post.
...ANSWER
Answered 2018-Jan-26 at 00:47I added a hello world TLS PR to the grpc-java project here https://github.com/grpc/grpc-java/pull/3992
the latest version of grpc-java as soon as this pr is merged will have a really nice working hello-world example. So all you have to do is git clone that project from master, and look at the example/README.md.
QUESTION
In this example https://github.com/grpc/grpc-java/blob/master/interop-testing/src/test/java/io/grpc/testing/integration/TlsTest.java you see that the TLS client connection has various TLS parameters such as
...ANSWER
Answered 2018-Jan-20 at 14:52TLS configuration is complex and dependent on the implementation, and ManagedChannelBuilder
can be used with things other than TLS. Thus, ManagedChannelBuilder
only has coarse configuration of TLS (on/off). This works well in the common web browser TLS situation of 1) no client certificate and 2) the server certificate is signed by a CA that chains to a root CA in the client's trust store.
However, there is more specific configuration available on NettyChannelBuilder
and OkHttpChannelBuilder
. How to configure TLS is different for each, because the implementation is different. The sslContext
from your first code snippet is a Netty object; that obviously would be poor configuration in OkHttpChannelBuilder
.
ManagedChannelBuilder
isn't supposed to have "all the options." It's supposed to have common options that exist across the transport implementations. More specific options are available on the specific transport implementation builders like NettyChannelBuilder
and OkHttpChannelBuilder
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install interop-test
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page