chia7712 commented on code in PR #22513:
URL: https://github.com/apache/kafka/pull/22513#discussion_r4667559605
##########
clients/src/main/java/org/apache/kafka/common/security/ssl/DefaultSslEngineFactory.java:
##########
@@ -212,6 +215,37 @@ private SSLEngine createSslEngine(ConnectionMode
connectionMode, String peerHost
}
return sslEngine;
}
+
+ // package access for testing
+ static String[] filterCipherSuites(List<String> configured, String[]
supported) {
+ // SSLParameters#getCipherSuites may return null. If the provider does
not report its supported
+ // cipher suites we cannot filter, so use the configured list
unchanged to fall back to the old behavior.
+ if (supported == null) {
+ log.warn("Skipping validation of configured cipher suites {}
because the JDK security provider does not report its supported cipher suites",
configured);
+ return configured.toArray(new String[0]);
+ }
+
+ Set<String> supportedCiphers = new HashSet<>(Arrays.asList(supported));
+ List<String> accepted = configured.stream()
+ .filter(supportedCiphers::contains)
+ .collect(Collectors.toList());
+
+ if (accepted.isEmpty()) {
+ throw new InvalidConfigurationException(
+ "None of the cipher suites in " + configured +
+ " are supported by the JDK security provider. " +
+ "Supported cipher suites are: " + supportedCiphers);
+ }
+
+ if (accepted.size() < configured.size()) {
+ List<String> differences = new ArrayList<>(configured);
+ differences.removeAll(accepted);
+ log.warn("Configured cipher suites filtered from {} to {} based on
JDK support. Unsupported cipher suites: {}. Effective cipher suites: {}",
Review Comment:
What if users fat-finger a cipher name? If the fail-fast is converted to a
log, they may never be aware of it :(
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]