|
18 | 18 | import javax.net.ssl.SSLContext;
|
19 | 19 | import javax.net.ssl.SSLException;
|
20 | 20 |
|
| 21 | +import java.util.Collection; |
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Locale;
|
| 24 | +import java.util.Optional; |
23 | 25 |
|
24 | 26 | import io.grpc.BindableService;
|
25 | 27 | import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
|
@@ -48,6 +50,22 @@ public class SecureNetty4GrpcServerTransport extends Netty4GrpcServerTransport {
|
48 | 50 | GRPC_SECURE_TRANSPORT_SETTING_KEY
|
49 | 51 | );
|
50 | 52 |
|
| 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 | + |
51 | 69 | /**
|
52 | 70 | * Creates a new SecureNetty4GrpcServerTransport instance and inject a SecureAuxTransportSslContext
|
53 | 71 | * into the NettyServerBuilder config to enable TLS on the server.
|
@@ -75,8 +93,7 @@ public SecureNetty4GrpcServerTransport(
|
75 | 93 |
|
76 | 94 | private JdkSslContext getSslContext(Settings settings, SecureAuxTransportSettingsProvider provider) throws SSLException {
|
77 | 95 | 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); |
80 | 97 | ClientAuth clientAuth = ClientAuth.valueOf(params.clientAuth().orElseThrow().toUpperCase(Locale.ROOT));
|
81 | 98 | return new JdkSslContext(
|
82 | 99 | sslContext,
|
|
0 commit comments