Configuring KTOR clients to use HTTP proxy information

I’m developing a plugin which acts as a client for a lot of HTTP requests. The platform now provides KTOR which I could use as a client, but previously the only way to ensure that requests obeyed all the users proxy config etc was to use the HttpRequests class. Is there now any way to configure KTOR to obey the user’s config and get a better HTTP client implementation?

We ship our own KTor so it newer then the platform one (we need bug fixes in KTor and older IDE versions lack them). We use the OkHttp client and configure it like so

            return OkHttp.create {
                config {
                    proxySelector(java.net.ProxySelector.getDefault())
                    proxyAuthenticator(okhttp3.Authenticator.JAVA_NET_AUTHENTICATOR)

                    val certificateManager = com.intellij.util.net.ssl.CertificateManager.Companion.getInstance()
                    sslSocketFactory(
                        certificateManager.sslContext.socketFactory,
                        certificateManager.trustManager
                    )
                }
            }

The platform sets the defaults to be the IDEs during AppInit which is why it uses the default JVM ones

2025.2+ seems to ship a new PlatformHttpClient, based on Java 11’s new HTTP client.