https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
p

Patrick

02/11/2020, 9:06 AM
I'm trying to use Ktor on native (MacOS, Windows 10) using curl.
Copy code
val client = HttpClient(Curl) {
    install(JsonFeature) {
        serializer = KotlinxSerializer()
    }
}

val response = client.get<String>("<https://google.com>")

println(response)
This code works fine on MacOS, but fails on windows with this error message:
Copy code
Uncaught Kotlin exception: io.ktor.client.engine.curl.CurlIllegalStateException: Connection failed for request: CurlRequestData(url='<https://google.com/>', method='GET', content: 0 bytes)
        at kfun:kotlin.Throwable.<init>(kotlin.String?;kotlin.Throwable?)kotlin.Throwable (000000000045bbc0)
        at kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable (000000000045beb0)
        at kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception (0000000000455160)
        at kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException (0000000000454ca0)
        at kfun:kotlin.IllegalStateException.<init>(kotlin.String?)kotlin.IllegalStateException (0000000000455330)
        at kfun:io.ktor.client.engine.curl.CurlIllegalStateException.<init>(kotlin.String)io.ktor.client.engine.curl.CurlIllegalStateException (00000000006d72d0)
        at kfun:io.ktor.client.engine.curl.internal.CurlMultiApiHandler.readResponseDataFromEasyHandle#internal (00000000006ded80)
        at kfun:io.ktor.client.engine.curl.internal.CurlMultiApiHandler.collectCompleted#internal (00000000006de290)
        at kfun:io.ktor.client.engine.curl.internal.CurlMultiApiHandler.pollCompleted(<http://kotlin.Int|kotlin.Int>)kotlin.collections.List<io.ktor.client.engine.curl.internal.CurlResponseData> (00000000006dd400)
        at kfun:io.ktor.client.engine.curl.pollCompleted$ktor-client-curl()kotlin.collections.List<io.ktor.client.engine.curl.internal.CurlResponseData> (00000000006d9cc0)
        at kfun:io.ktor.client.engine.curl.CurlProcessor.poll$lambda-6#internal (00000000006d94f0)
        at _ZN6Worker19processQueueElementEb (00000000008900c0)
        at _ZN12_GLOBAL__N_113workerRoutineEPv (00000000008915e0)
        at pthread_create_wrapper (00000000008c1850)
        at  (00007ffdcfd2b02c)
        at  (00007ffdcfd2b0a0)
        at  (00007ffdd04c7bc0)
        at  (00007ffdd0f0ceb0)
Does anyone have an idea why this does not work?
m

msink

02/11/2020, 9:08 AM
Does it work with
http://
?
p

Patrick

02/11/2020, 9:19 AM
Yes it does! What do I need to change to make it work with https?
m

msink

02/11/2020, 9:23 AM
Most likely - it did not find certificates directory.
p

Patrick

02/11/2020, 9:24 AM
You mean curl could not find any root certificates, therefore it could not check if the certificate of google was valid? How do I point it to the correct directory?
m

msink

02/11/2020, 9:41 AM
By default it looks for it in path relative to
.exe
-
../ssl/certs
p

Patrick

02/11/2020, 9:41 AM
Hmm I guess that won't work since this .exe needs to be executed from anywhere
Windows has a default path for certs, right? I'm just asking because it does not seem to be a problem if I use curl on the command line.
m

msink

02/11/2020, 9:43 AM
Really it's not Kotlin related, it uses openssl from msys2, try ask msys2 people
p

Patrick

02/11/2020, 9:44 AM
I will, thanks for your help
8 Views