Getting this exceptions for the ssl bit of my code...
# ktor
o
Getting this exceptions for the ssl bit of my code
Copy code
constructor(Port: Int = 6697,Address: String): super() {
        runBlocking {
            try {
                port = Port
                address = Address
                socket = aSocket(ActorSelectorManager(ioCoroutineDispatcher)).
                        tcp().connect(InetSocketAddress(address,port)).tls()
                input = socket.openReadChannel()
                output = socket.openWriteChannel(autoFlush = false)
                connected = true
            } catch(e: Throwable) {
                e.printStackTrace()
                socket.close()
                connected = false
            }
        }
    }
Copy code
java.lang.IllegalStateException: Check failed.
	at io.ktor.network.tls.TLSClientHandshake.handleCertificatesAndKeys(TLSClientHandshake.kt:244)
	at io.ktor.network.tls.TLSClientHandshake$handleCertificatesAndKeys$1.doResume(TLSClientHandshake.kt)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
	at kotlinx.coroutines.experimental.AbstractContinuation.run(AbstractContinuation.kt:19)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.connection.SslConnection.<init>(SslConnection.kt:15)
	at com.github.otakusenpai.testbot.MainKt$main$1.doResume(main.kt:73)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.MainKt.main(main.kt:48)
Copy code
kotlin.UninitializedPropertyAccessException: lateinit property socket has not been initialized
	at com.github.otakusenpai.testbot.connection.Connection.getSocket(Connection.kt:26)
	at com.github.otakusenpai.testbot.connection.SslConnection$1.doResume(SslConnection.kt:26)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resumeWithException(CoroutineImpl.kt:48)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resumeWithException(CoroutineImpl.kt:47)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resumeWithException(CoroutineImpl.kt:47)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
	at kotlinx.coroutines.experimental.AbstractContinuation.run(AbstractContinuation.kt:19)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.connection.SslConnection.<init>(SslConnection.kt:15)
	at com.github.otakusenpai.testbot.MainKt$main$1.doResume(main.kt:73)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.MainKt.main(main.kt:48)
@Deactivated User how do I initialise a SSL Raw Socket ?
c
Are you sure that the remote peer works with TLS?
// cc @e5l
o
yes it should provide tls over 6697
@cy ^
d
have you tried other endpoint with ssl working?
which is the host?
c
The other alternative is to try to connect to the same host\port with s_client tool
o
port 6697
d
have you tried the other alternate two ports in the case they serve different ssl certificates? https://freenode.net/kb/answer/chat 7000 and 7070?
o
let me try
same behaviour with port 7000 and 7070
d
okay, still that might be a bug or something missing in the cio ssl implementation, so I guess you should fill an issue
o
do you need the code sample ?
ok
d
Happens when connecting without needing to send anything right?
I guess adding the line you use to connect the socket with the host and the port would be enough
o
yeah, during my SslConnectionn class instialisation
d
try to reproduce it with an one-liner creating the socket and put it in the issue
o
ok
@Deactivated User will this code do?
Copy code
fun main(args: Array<String>) = runBlocking {
    lateinit var output : ByteWriteChannel
    lateinit var input: ByteReadChannel
    var socket = aSocket(ActorSelectorManager(ioCoroutineDispatcher)).tcp()
            .connect(InetSocketAddress("<http://chat.freenode.net|chat.freenode.net>",6697)).tls()
    input = socket.openReadChannel()
    output = socket.openWriteChannel(autoFlush = true)
    socket.close()
}
d
Yeah, if it reproduces the problem, it is enough 👍.
o
e
It is the problem with missing
ClientCertificate
.
<http://chat.freenode.net|chat.freenode.net>
requires additional client authentication.