Skip to content
Merged
6 changes: 6 additions & 0 deletions core/src/main/java/io/grpc/ForwardingChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public T usePlaintext(boolean skipNegotiation) {
return thisT();
}

@Override
public T useTransportSecurity() {
delegate().useTransportSecurity();
return thisT();
}

@Override
public T nameResolverFactory(NameResolver.Factory resolverFactory) {
delegate().nameResolverFactory(resolverFactory);
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/io/grpc/ManagedChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ public static ManagedChannelBuilder<?> forTarget(String target) {
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1772")
public abstract T usePlaintext(boolean skipNegotiation);

/**
* Makes the client use TLS.
*
* @return this
* @throws UnsupportedOperationException if transport security is not supported.
* @since 1.9.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3713")
public T useTransportSecurity() {
throw new UnsupportedOperationException();
}

/**
* Provides a custom {@link NameResolver.Factory} for the channel. If this method is not called,
* the builder will try the providers listed by {@link NameResolverProvider#providers()} for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public final InProcessChannelBuilder maxInboundMessageSize(int max) {
return super.maxInboundMessageSize(max);
}

/**
* Does nothing.
*/
@Override
public InProcessChannelBuilder useTransportSecurity() {
return this;
}

/**
* Does nothing.
*/
Expand Down
9 changes: 9 additions & 0 deletions netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ public NettyChannelBuilder usePlaintext(boolean skipNegotiation) {
return this;
}

/**
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code TLS}.
*/
@Override
public NettyChannelBuilder useTransportSecurity() {
negotiationType(NegotiationType.TLS);
return this;
}

/**
* Enable keepalive with default delay and timeout.
*
Expand Down
9 changes: 9 additions & 0 deletions okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ public final OkHttpChannelBuilder usePlaintext(boolean skipNegotiation) {
return this;
}

/**
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code TLS}.
*/
@Override
public final OkHttpChannelBuilder useTransportSecurity() {
negotiationType(NegotiationType.TLS);
return this;
}

@Override
@Internal
protected final ClientTransportFactory buildTransportFactory() {
Expand Down