rspec/rules/S4423/java/rule.adoc

21 lines
1.4 KiB
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
``++javax.net.ssl.SSLContext.getInstance++`` returns a SSLContext object that implements the specified secure socket protocol. However, older protocol versions like "SSLv3" have been proven to be insecure.
This rule raises an issue when an ``++SSLContext++`` is created with an insecure protocol version(ie: a protocol different from "TLS", "DTLS", "TLSv1.2", "DTLSv1.2", "TLSv1.3", "DTLSv1.3").
2020-06-30 12:49:37 +02:00
The recommended value is "TLS" or "DTLS" as it will always use the latest version of the protocol. However an issue will be raised if the bytecode was compiled with JDK7 or an even older version of JDK because they are not alias for TLSv1.2 and DTLSv1.2 but for weaker protocols.
2021-01-27 13:42:22 +01:00
Note that calling ``++SSLContext.getInstance(...)++`` with "TLSv1.2" or "DTLSv1.2" doesn't prevent protocol version negotiation. For example, if a client connects with "TLSv1.1" and the server used ``++SSLContext.getInstance("TLSv1.2")++``, the connection will use "TLSv1.1". It is possible to enable only specific protocol versions by calling ``++setEnabledProtocols++`` on ``++SSLSocket++``, ``++SSLServerSocket++`` or ``++SSLEngine++``. However this should be rarely needed as clients usually ask for the most secure protocol supported.
2020-06-30 12:49:37 +02:00
== Noncompliant Code Example
----
context = SSLContext.getInstance("SSLv3"); // Noncompliant
----
== Compliant Solution
----
context = SSLContext.getInstance("TLSv1.2");
----
include::../see.adoc[]