2024-01-25 15:18:07 +01:00
|
|
|
== How to fix it in Java Cryptography Extension
|
2023-06-20 17:36:01 +02:00
|
|
|
|
|
|
|
=== Code examples
|
|
|
|
|
|
|
|
==== Noncompliant code example
|
|
|
|
|
|
|
|
[source,java,diff-id=1,diff-type=noncompliant]
|
|
|
|
----
|
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
try {
|
|
|
|
SSLContext.getInstance("TLSv1.1"); // Noncompliant
|
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
|
|
|
|
[source,java,diff-id=1,diff-type=compliant]
|
|
|
|
----
|
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
try {
|
|
|
|
SSLContext.getInstance("TLSv1.2");
|
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
=== How does this work?
|
|
|
|
|
|
|
|
include::../../common/fix/fix.adoc[]
|