https://kotlinlang.org logo
#ktor
Title
# ktor
x

xxfast

05/18/2022, 3:25 AM
Hi all. Im trying to disable ssl for my ktor client. I've been following this stackoverflow post. However, my project is an multiplatform project, and i'm making use of the default engine to create my client in
commonMain
. Given that this ssl-disabling is slightly different for each engine, is there a way to do this neatly for each engine without having to `expect`/`actual` the whole engines for each platforms?
m

Michael Friend

05/18/2022, 3:05 PM
Since the disabling logic is very different for each platform there’s no way to do it in common for every platform, at least that ive found. Another catch w that I’ve run into that would prevent a common method is that you cant actually disable it for JS running on browser afaik, just for Node
😥 1
x

xxfast

05/19/2022, 12:26 AM
yeah ended up giving up having to `expect`/`actual` the whole engines for each platforms
Copy code
@HttpClientDsl
expect fun HttpClient(
  block: HttpClientConfig<*>.() -> Unit = {}
): HttpClient

//androidMain
@HttpClientDsl
actual fun HttpClient(
  block: HttpClientConfig<*>.() -> Unit,
): HttpClient = HttpClient(CIO) {
  engine {
    https {
      trustManager = TrustAllManager
    }
  }

  block()
}
63 Views