otakusenpai
04/24/2018, 1:14 PMDeactivated User
04/24/2018, 1:33 PMktor-network-tls
artifact, and then call the tls method:
aSocket().tcp().connect().tls(...)
otakusenpai
04/24/2018, 1:34 PMDeactivated User
04/24/2018, 1:53 PMtls_sample.kts
#!/usr/bin/env kscript
@file:MavenRepository("ktor", "<https://kotlin.bintray.com/ktor>")
@file:DependsOn("io.ktor:ktor-network-tls:0.9.2")
import io.ktor.cio.*
import io.ktor.network.sockets.*
import io.ktor.network.tls.*
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.io.*
import java.net.*
runBlocking {
val socket = aSocket().tcp().connect(InetSocketAddress("<http://google.com|google.com>", 443)).tls()
val w = socket.openWriteChannel(autoFlush = false)
w.write("GET / HTTP/1.1\r\n")
w.write("Host: <http://google.com|google.com>\r\n")
w.write("\r\n")
w.flush()
val r = socket.openReadChannel()
println(r.readASCIILine())
}
otakusenpai
04/24/2018, 2:42 PMDeactivated User
04/24/2018, 2:43 PMotakusenpai
04/24/2018, 2:43 PMDeactivated User
04/24/2018, 2:43 PMotakusenpai
04/24/2018, 2:43 PMDeactivated User
04/24/2018, 2:43 PMotakusenpai
04/24/2018, 2:43 PMDeactivated User
04/24/2018, 2:44 PMotakusenpai
04/24/2018, 2:46 PMDeactivated User
04/24/2018, 2:47 PMotakusenpai
04/24/2018, 2:47 PMDeactivated User
04/24/2018, 2:48 PMotakusenpai
04/24/2018, 2:50 PMDeactivated User
04/24/2018, 2:53 PMe5l
04/24/2018, 2:54 PMDeactivated User
04/24/2018, 2:54 PMotakusenpai
04/24/2018, 2:54 PMDeactivated User
04/24/2018, 3:00 PMe5l
04/24/2018, 3:05 PMotakusenpai
04/24/2018, 3:06 PMDeactivated User
04/24/2018, 3:08 PMval socket = aSocket().tcp().connect(InetSocketAddress("<http://chat.freenode.net|chat.freenode.net>", 6697)).tls()
//Exception in thread "main" Exception in thread "io-thread-2" io.ktor.network.tls.TLSException: Unsupported TLS handshake type CertificateRequest
otakusenpai
04/24/2018, 3:12 PMDeactivated User
04/24/2018, 3:14 PMotakusenpai
04/24/2018, 3:14 PMDeactivated User
04/24/2018, 3:24 PMval socket = aSocket().tcp().connect(InetSocketAddress("<http://chat.freenode.net|chat.freenode.net>", 6697)).tls()
For now, connect to the unsecure version (6667 without tls), we will look at it.otakusenpai
04/24/2018, 3:24 PM