2023-06-20 17:36:01 +02:00
|
|
|
== How to fix it in OkHttp
|
|
|
|
|
|
|
|
=== Code examples
|
|
|
|
|
|
|
|
==== Noncompliant code example
|
|
|
|
|
2023-08-15 13:34:10 +02:00
|
|
|
[source,kotlin,diff-id=11,diff-type=noncompliant]
|
2023-06-20 17:36:01 +02:00
|
|
|
----
|
|
|
|
import okhttp3.ConnectionSpec;
|
|
|
|
import okhttp3.TlsVersion;
|
|
|
|
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
|
|
|
.tlsVersions(TlsVersion.TLS_1_1) // Noncompliant
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
|
2023-08-15 13:34:10 +02:00
|
|
|
[source,kotlin,diff-id=11,diff-type=compliant]
|
2023-06-20 17:36:01 +02:00
|
|
|
----
|
|
|
|
import okhttp3.ConnectionSpec;
|
|
|
|
import okhttp3.TlsVersion;
|
|
|
|
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
|
|
|
.tlsVersions(TlsVersion.TLS_1_2)
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
=== How does this work?
|
|
|
|
|
|
|
|
include::../../common/fix/fix.adoc[]
|