diff --git a/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java b/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java index c0fcb3e8d1..a3afeda3fe 100644 --- a/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java +++ b/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java @@ -266,6 +266,12 @@ final class CipherSuiteConverter { return hmacAlgo; } + /** + * Convert from OpenSSL cipher suite name convention to java cipher suite name convention. + * @param openSslCipherSuite An OpenSSL cipher suite name. + * @param protocol The cryptographic protocol (i.e. SSL, TLS, ...). + * @return The translated cipher suite name according to java conventions. This will not be {@code null}. + */ static String toJava(String openSslCipherSuite, String protocol) { Map p2j = o2j.get(openSslCipherSuite); if (p2j == null) { diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java index 820223f4bd..d7f8c5af28 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java @@ -715,9 +715,7 @@ public final class OpenSslEngine extends SSLEngine { return EmptyArrays.EMPTY_STRINGS; } else { for (int i = 0; i < enabled.length; i++) { - String c = enabled[i]; - // TODO: Determine the protocol using SSL_CIPHER_get_version() - String mapped = CipherSuiteConverter.toJava(c, "TLS"); + String mapped = toJavaCipherSuite(enabled[i]); if (mapped != null) { enabled[i] = mapped; } @@ -1084,7 +1082,7 @@ public final class OpenSslEngine extends SSLEngine { if (applicationProtocol != null) { OpenSslEngine.this.applicationProtocol = applicationProtocol.replace(':', '_'); } else { - OpenSslEngine.this.applicationProtocol = ""; + OpenSslEngine.this.applicationProtocol = applicationProtocol = ""; } } String version = SSL.getVersion(ssl); @@ -1241,13 +1239,7 @@ public final class OpenSslEngine extends SSLEngine { } String prefix = toJavaCipherSuitePrefix(SSL.getVersion(ssl)); - String converted = CipherSuiteConverter.toJava(openSslCipherSuite, prefix); - if (converted != null) { - openSslCipherSuite = converted; - } else { - openSslCipherSuite = prefix + '_' + openSslCipherSuite.replace('-', '_'); - } - return openSslCipherSuite; + return CipherSuiteConverter.toJava(openSslCipherSuite, prefix); } /**