Vita Sokolova
02/27/2025, 9:29 AMCertificatePinner
api, but also pinning error doesn’t trigger HttpResponseValidator
. How can I configure HttpClient
to catch this error?Aleksei Tirman [JB]
02/27/2025, 11:39 AMCertificatePinner
for the Darwin engine? If so, have you tried catching the TlsPeerUnverifiedException
introduced in Ktor 3.1.0?Vita Sokolova
02/27/2025, 12:08 PMVita Sokolova
02/27/2025, 12:10 PMif (engineConfig is DarwinClientEngineConfig) {
val builder = CertificatePinner.Builder()
listOf("host" to "pinSHA").forEach { (host, pinSHA) ->
builder.add(host, pinSHA)
}
engineConfig.handleChallenge(builder.build())
}
Vita Sokolova
02/27/2025, 12:12 PMif (engineConfig is OkHttpConfig) {
engineConfig.config {
certificatePinner(
CertificatePinner.Builder().apply {
listOf("host" to "pinSHA").forEach { (host, pinSHA) ->
add(host, pinSHA)
}
}.build()
)
}
}
Aleksei Tirman [JB]
02/27/2025, 4:38 PMVita Sokolova
02/27/2025, 8:28 PMHttpResponseValidator
https://ktor.io/docs/client-response-validation.html#non-2xxVita Sokolova
02/27/2025, 8:29 PMAleksei Tirman [JB]
02/28/2025, 8:54 AM