Separate certificate-chain validation from hostname verification and repair trust-all mobile clients with platform trust.
Intermediate45 min·updated 2026-11-15
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
Encryption needs an authenticated peer
HTTPS can protect confidentiality and integrity only when the client validates the intended server under its trust policy. A connection can be encrypted to an impostor if certificate validation is disabled. The URL beginning with https:// does not prove the application checked who received the credentials.
CareConnect builds an OkHttp client with a custom X509TrustManager whose checkServerTrusted() method is empty. It also installs a HostnameVerifier that always returns true. Retrofit uses that client for login. Under a network-interception position, an attacker-controlled server certificate can be accepted and receive the login request.
The empty accepted-issuer array alone is not the full proof; trace the no-op server check, the installed socket factory, the hostname verifier, and the actual HTTP client used by the sensitive call.
Continue with Premium
Continue API Security with the complete lessons, guided exercises, code-review challenges and assessments.