Skip to content

Commit

Permalink
add tls configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vendelieu committed Oct 10, 2024
1 parent 6e32678 commit 2e2f851
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ configureKotlin {
implementation(libs.ktor.network)
implementation(libs.kotlinx.io.core)

api(libs.ktor.network.tls)
api(libs.bignum)
api(libs.coroutines.core)
api(libs.kotlinx.datetime)
Expand All @@ -47,7 +48,7 @@ configureKotlin {
}
implementation("commons-io:commons-io:2.14.0")
implementation("org.apache.commons:commons-compress:1.26.0")
implementation("com.fasterxml.woodstox:woodstox-core:6.4.0")
implementation("com.fasterxml.woodstox:woodstox-core:6.5.0")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ logback = "1.5.8"
kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "io" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "datetime" }
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
ktor-network-tls = { module = "io.ktor:ktor-network-tls", version.ref = "ktor" }
bignum = { module = "com.ionspin.kotlin:bignum", version.ref = "bignum" }

coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.vendeli.rethis.types.core

import io.ktor.network.tls.*
import io.ktor.utils.io.charsets.*
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
Expand All @@ -10,6 +11,7 @@ data class ClientConfiguration(
var db: Int? = null,
var charset: Charset = Charsets.UTF_8,
var maxConnections: Int = 50,
var tlsConfig: TLSConfig? = null,
var dispatcher: CoroutineDispatcher = Dispatchers.IO,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import eu.vendeli.rethis.utils.readRedisMessage
import eu.vendeli.rethis.utils.writeRedisValue
import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.network.tls.*
import io.ktor.util.logging.*
import io.ktor.utils.io.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -33,6 +34,11 @@ internal class ConnectionPool(
val conn = aSocket(selector)
.tcp()
.connect(address)
.let { socket ->
client.cfg.tlsConfig?.let {
socket.tls(selector.coroutineContext, it)
} ?: socket
}
.connection()

val reqBuffer = Buffer()
Expand Down

0 comments on commit 2e2f851

Please sign in to comment.