Hi is there an easy way for the ktor http client t...
# ktor
t
Hi is there an easy way for the ktor http client to accept self signed certs for dev?
d
Looking for an answer to this as well
a
As a workaround, on the JVM target using CIO engine, you can accept all certificates:
Copy code
val client = HttpClient(CIO) {
    engine {
        https.trustManager = object : X509TrustManager {
            override fun checkClientTrusted(certs: Array<X509Certificate?>?, authType: String?) {}
            override fun checkServerTrusted(certs: Array<X509Certificate?>?, authType: String?) {}
            override fun getAcceptedIssuers(): Array<X509Certificate?> = arrayOfNulls(0)
        }
    }
}
🙏 1
Also, you can add a certificate chain:
Copy code
HttpClient(CIO) {
    engine {
        https.addCertificateChain(...)
    }
}
👍 1