Sagar Khurana
03/22/2026, 6:44 AMval pinner = CertificatePinner.Builder()
.add("api.example.com", "sha256/leafHash=", "sha256/intermediateHash=")
.build()
HttpClient(Darwin) {
engine {
handleChallenge { session, task, challenge, completionHandler ->
try {
pinner.invoke(session, task, challenge, completionHandler)
} catch (e: Exception) {
// Pin mismatch — fall back to default TLS
completionHandler(
NSURLSessionAuthChallengePerformDefaultHandling, null
)
}
}
}
}
Is there a better pattern for soft-fail pinning with the Darwin engine, or is wrapping with try/catch the right approach?Aleksei Tirman [JB]
03/23/2026, 9:37 AM