Skip to content

Support custom KeyManager with TlsChannelCredentials #7667

Description

@arithmetic1728

I am working on adding mtls feature to Google gax-java library PR. We need to add ssl context to ManagedChannelBuilder. The code in my PR looks like this:

import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;

private ManagedChannel createSingleChannel() throws IOException {
    ...
    ManagedChannelBuilder builder;
    SslContext sslContext = createSslContext();
    if (sslContext != null) {
      builder = ((NettyChannelBuilder) builder).sslContext(sslContext);
    }
    ...
    ManagedChannel managedChannel = builder.build();
    return managedChannel;
}

In the code I cast the builder type from ManagedChannelBuilder to NettyChannelBuilder, and add the ssl context. This code is for grpc so the cast works.

Our concern is that NettyChannelBuilder is from io.grpc.netty.shaded.io.grpc.netty. It is supposed to be private to grpc-java I guess.

My question is: is this OK? If not, how can I pass the ssl context to the ManagedChannelBuilder. We must use ManagedChannelBuilder to build the channel (because we provide the user a callback to configure ManagedChannelBuilder), otherwise this will be a major breaking change for all googleapis client libraries.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions