cast/protocol: fix all lint findings
- Commit
090fc1d6386993fdafb23306af659245ff3ee960- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 05:20 UTC (19 days ago)
- Parents
0428bb8
Fix the lint warning reported for the cast/protocol module's own sources by :cast:protocol:lint, now 0 errors / 0 warnings for cast/protocol/**. CustomX509TrustManager in EphemeralTls: suppressed with a precise justification, because inspection shows it is not blind trust — PinnedTrustManager.checkServerTrusted accepts exactly one leaf whose SHA-256 fingerprint equals the session pin (constant-time MessageDigest.isEqual) and throws CertificateException otherwise, checkClientTrusted always throws, and getAcceptedIssuers is empty. The pin arrives over the pairing-authenticated AES-256-GCM control channel for the E2EE pairing channel's ephemeral self-signed certificate, so validation is strengthened, not disabled. Annotation and comment only: no wire-format or crypto behaviour changed. No lint config or baseline changed. Verified: ./gradlew :cast:protocol:lint (0 own-module errors/warnings) and :cast:protocol:testDebugUnitTest green (178 tests).
Diff
cast/protocol/src/main/java/com/vayunmathur/cast/protocol/EphemeralTls.kt
diff --git a/cast/protocol/src/main/java/com/vayunmathur/cast/protocol/EphemeralTls.kt b/cast/protocol/src/main/java/com/vayunmathur/cast/protocol/EphemeralTls.ktindex f21dc8ef68..c900ffd6b0 100644--- a/cast/protocol/src/main/java/com/vayunmathur/cast/protocol/EphemeralTls.kt+++ b/cast/protocol/src/main/java/com/vayunmathur/cast/protocol/EphemeralTls.kt@@ -1,5 +1,6 @@ package com.vayunmathur.cast.protocol +import android.annotation.SuppressLint import java.io.ByteArrayInputStream import java.math.BigInteger import java.net.InetAddress@@ -142,6 +143,15 @@ object EphemeralTls { fun fingerprintOf(certificate: X509Certificate): ByteArray = MessageDigest.getInstance("SHA-256").digest(certificate.encoded) + // CustomX509TrustManager suppressed with justification: this is not a+ // permissive trust manager. checkServerTrusted accepts exactly one leaf+ // whose SHA-256 fingerprint equals the session pin (constant-time+ // MessageDigest.isEqual) and throws CertificateException otherwise;+ // checkClientTrusted always throws and no issuers are accepted. The pin+ // arrives over the pairing-authenticated, AES-256-GCM control channel, so+ // certificate validation is strengthened, not disabled. Wire format and+ // crypto behaviour are unchanged.+ @SuppressLint("CustomX509TrustManager") private class PinnedTrustManager(private val fingerprint: ByteArray) : X509TrustManager { override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) {