Skip to content

Commit a07c01b

Browse files
Add default SecureAuxTransportParameters.
Default client auth to required as it is most restrictive. Default cipher suites to empty - Use netty defaults. Signed-off-by: Finn Carroll <[email protected]>
1 parent 9a7212e commit a07c01b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Diff for: plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/ssl/SecureNetty4GrpcServerTransport.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import javax.net.ssl.SSLContext;
1919
import javax.net.ssl.SSLException;
2020

21+
import java.util.Collection;
2122
import java.util.List;
2223
import java.util.Locale;
24+
import java.util.Optional;
2325

2426
import io.grpc.BindableService;
2527
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
@@ -48,6 +50,22 @@ public class SecureNetty4GrpcServerTransport extends Netty4GrpcServerTransport {
4850
GRPC_SECURE_TRANSPORT_SETTING_KEY
4951
);
5052

53+
/**
54+
* In the case no SecureAuxTransportParameters restrict client auth mode to REQUIRE.
55+
* Assume no enabled cipher suites. Allow ssl context implementation to select defaults.
56+
*/
57+
private static class DefaultParameters implements SecureAuxTransportSettingsProvider.SecureAuxTransportParameters {
58+
@Override
59+
public Optional<String> clientAuth() {
60+
return Optional.of(ClientAuth.REQUIRE.name());
61+
}
62+
63+
@Override
64+
public Collection<String> cipherSuites() {
65+
return List.of();
66+
}
67+
}
68+
5169
/**
5270
* Creates a new SecureNetty4GrpcServerTransport instance and inject a SecureAuxTransportSslContext
5371
* into the NettyServerBuilder config to enable TLS on the server.
@@ -75,8 +93,7 @@ public SecureNetty4GrpcServerTransport(
7593

7694
private JdkSslContext getSslContext(Settings settings, SecureAuxTransportSettingsProvider provider) throws SSLException {
7795
SSLContext sslContext = provider.buildSecureAuxServerTransportContext(settings, this).orElseThrow(IllegalArgumentException::new);
78-
SecureAuxTransportSettingsProvider.SecureAuxTransportParameters params = provider.parameters()
79-
.orElseThrow(IllegalArgumentException::new);
96+
SecureAuxTransportSettingsProvider.SecureAuxTransportParameters params = provider.parameters().orElseGet(DefaultParameters::new);
8097
ClientAuth clientAuth = ClientAuth.valueOf(params.clientAuth().orElseThrow().toUpperCase(Locale.ROOT));
8198
return new JdkSslContext(
8299
sslContext,

0 commit comments

Comments
 (0)