package bou.amine.apps.readerforselfossv2.rest

import io.ktor.client.engine.cio.CIOEngineConfig
import java.security.cert.X509Certificate
import javax.net.ssl.X509TrustManager

class NaiveTrustManager : X509TrustManager {
    override fun checkClientTrusted(
        chain: Array<out X509Certificate>?,
        authType: String?,
    ) {}

    override fun checkServerTrusted(
        chain: Array<out X509Certificate>?,
        authType: String?,
    ) {}

    override fun getAcceptedIssuers(): Array<out X509Certificate> = arrayOf()
}

actual fun setupInsecureHTTPEngine(config: CIOEngineConfig) {
    config.https.trustManager = NaiveTrustManager()
}
