SonarQube issues OpenSslEngine
Motivation: SonarQube (clinker.netty.io/sonar) reported a few 'critical' issues related to the OpenSslEngine. Modifications: - Remove potential for dereference of null variable. - Remove duplicate null check and TODO cleanup. Results: Less potential for null dereference, cleaner code, and 1 less TODO.
This commit is contained in:
parent
8bbfcb05a0
commit
50a857cecf
@ -266,6 +266,12 @@ final class CipherSuiteConverter {
|
|||||||
return hmacAlgo;
|
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) {
|
static String toJava(String openSslCipherSuite, String protocol) {
|
||||||
Map<String, String> p2j = o2j.get(openSslCipherSuite);
|
Map<String, String> p2j = o2j.get(openSslCipherSuite);
|
||||||
if (p2j == null) {
|
if (p2j == null) {
|
||||||
|
@ -715,9 +715,7 @@ public final class OpenSslEngine extends SSLEngine {
|
|||||||
return EmptyArrays.EMPTY_STRINGS;
|
return EmptyArrays.EMPTY_STRINGS;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < enabled.length; i++) {
|
for (int i = 0; i < enabled.length; i++) {
|
||||||
String c = enabled[i];
|
String mapped = toJavaCipherSuite(enabled[i]);
|
||||||
// TODO: Determine the protocol using SSL_CIPHER_get_version()
|
|
||||||
String mapped = CipherSuiteConverter.toJava(c, "TLS");
|
|
||||||
if (mapped != null) {
|
if (mapped != null) {
|
||||||
enabled[i] = mapped;
|
enabled[i] = mapped;
|
||||||
}
|
}
|
||||||
@ -1084,7 +1082,7 @@ public final class OpenSslEngine extends SSLEngine {
|
|||||||
if (applicationProtocol != null) {
|
if (applicationProtocol != null) {
|
||||||
OpenSslEngine.this.applicationProtocol = applicationProtocol.replace(':', '_');
|
OpenSslEngine.this.applicationProtocol = applicationProtocol.replace(':', '_');
|
||||||
} else {
|
} else {
|
||||||
OpenSslEngine.this.applicationProtocol = "";
|
OpenSslEngine.this.applicationProtocol = applicationProtocol = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String version = SSL.getVersion(ssl);
|
String version = SSL.getVersion(ssl);
|
||||||
@ -1241,13 +1239,7 @@ public final class OpenSslEngine extends SSLEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String prefix = toJavaCipherSuitePrefix(SSL.getVersion(ssl));
|
String prefix = toJavaCipherSuitePrefix(SSL.getVersion(ssl));
|
||||||
String converted = CipherSuiteConverter.toJava(openSslCipherSuite, prefix);
|
return CipherSuiteConverter.toJava(openSslCipherSuite, prefix);
|
||||||
if (converted != null) {
|
|
||||||
openSslCipherSuite = converted;
|
|
||||||
} else {
|
|
||||||
openSslCipherSuite = prefix + '_' + openSslCipherSuite.replace('-', '_');
|
|
||||||
}
|
|
||||||
return openSslCipherSuite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user