- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: kotlin-security/enforce-secure-tls
Language: Kotlin
Severity: Error
Category: Security
CWE: 757
This rule enforces the use of secure Transport Layer Security (TLS) versions in Kotlin applications. TLS is a protocol that ensures privacy and data integrity between applications communicating over a network. Older versions of TLS, specifically versions 1.0 and 1.1, have known vulnerabilities and are no longer considered secure.
Failing to use a secure TLS version can expose sensitive information to attackers and compromise the security of your application. It’s crucial to ensure that your Kotlin application is configured to use a secure TLS version.
To adhere to this rule, always use TLS version 1.2 or 1.3 in your Kotlin code. For example, when using the OkHttpClient
library, you can specify the TLS version by using the ConnectionSpec.MODERN_TLS
or by manually setting the SSLContext to TLSv1.2
or TLSv1.3
. Avoid using ConnectionSpec.COMPATIBLE_TLS
, which allows for the use of insecure TLS versions.
import okhttp3.ConnectionSpec
import okhttp3.OkHttpClient
val client = OkHttpClient.Builder()
.connectionSpecs(listOf(ConnectionSpec.COMPATIBLE_TLS)) // Insecure: allows older versions
.build()
import javax.net.ssl.SSLContext
// Weak TLS versions
val sslContext1 = SSLContext.getInstance("TLSv1") // Insecure
val sslContext2 = SSLContext.getInstance("TLSv1.1") // Insecure
val sslContext3 = SSLContext.getInstance("SSLv3") // Insecure
// Weak configuration in OkHttpClient
val client = OkHttpClient.Builder()
.sslSocketFactory(sslContext1.socketFactory) // Noncompliant
.build()
import okhttp3.ConnectionSpec
import okhttp3.OkHttpClient
val client = OkHttpClient.Builder()
.connectionSpecs(listOf(ConnectionSpec.MODERN_TLS)) // Enforces TLS 1.2+
.build()
import javax.net.ssl.SSLContext
// Use TLS 1.2 or 1.3
val sslContext = SSLContext.getInstance("TLSv1.2") // TLSv1.3 also acceptable
// Configure OkHttpClient with strong TLS
val client = OkHttpClient.Builder()
.sslSocketFactory(sslContext.socketFactory)
.build()