
Co-authored-by: hendrik-buchwald-sonarsource <64110887+hendrik-buchwald-sonarsource@users.noreply.github.com>
40 lines
787 B
Plaintext
40 lines
787 B
Plaintext
== How to fix it in Java Cryptographic Extension
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,kotlin,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
import javax.net.ssl.SSLContext;
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
fun main(args: Array<String>) {
|
|
try {
|
|
SSLContext.getInstance("TLSv1.1"); // Noncompliant
|
|
} catch (e: NoSuchAlgorithmException) {
|
|
// ...
|
|
}
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,kotlin,diff-id=1,diff-type=compliant]
|
|
----
|
|
import javax.net.ssl.SSLContext;
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
fun main(args: Array<String>) {
|
|
try {
|
|
SSLContext.getInstance("TLSv1.2");
|
|
} catch (e: NoSuchAlgorithmException) {
|
|
// ...
|
|
}
|
|
}
|
|
----
|
|
|
|
=== How does this work?
|
|
|
|
include::../../common/fix/fix.adoc[]
|