Skip to content

Commit

Permalink
Add cipher suites to server config builder
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Jun 30, 2022
1 parent 0975470 commit a97d13c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/SslConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class SslConfig(

@JvmStatic
@JvmOverloads
fun server(ownCertChain: List<X509Certificate>, privateKey: PrivateKey, trustedCerts: List<X509Certificate> = listOf(), reqAuthentication: Boolean = true, cidSupplier: CidSupplier = EmptyCidSupplier, mtu: Int = 0, retransmitMin: Duration = ofSeconds(1), retransmitMax: Duration = ofSeconds(60)): SslConfig {
return create(true, null, null, listOf(), cidSupplier, ownCertChain, privateKey, trustedCerts, reqAuthentication, mtu, retransmitMin, retransmitMax)
fun server(ownCertChain: List<X509Certificate>, privateKey: PrivateKey, trustedCerts: List<X509Certificate> = listOf(), reqAuthentication: Boolean = true, cipherSuites: List<String> = emptyList(), cidSupplier: CidSupplier = EmptyCidSupplier, mtu: Int = 0, retransmitMin: Duration = ofSeconds(1), retransmitMax: Duration = ofSeconds(60)): SslConfig {
return create(true, null, null, cipherSuites, cidSupplier, ownCertChain, privateKey, trustedCerts, reqAuthentication, mtu, retransmitMin, retransmitMax)
}

private fun create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DtlsTransmitterCertTest {
serverConf = SslConfig.server(Certs.serverChain, Certs.server.privateKey, reqAuthentication = false, cidSupplier = randomCid)
val server = newServerDtlsTransmitter(7003)

val clientConf = SslConfig.client(trustedCerts = listOf(Certs.root.asX509()), cipherSuites = listOf("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256"))
val clientConf = SslConfig.client(trustedCerts = listOf(Certs.root.asX509()), cipherSuites = listOf("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256"))
val client = DtlsTransmitter.connect(srvTrans, clientConf, 7003).await()

client.send("dupa")
Expand All @@ -92,13 +92,13 @@ class DtlsTransmitterCertTest {
serverConf = SslConfig.server(Certs.serverLongChain, Certs.server2.privateKey, reqAuthentication = false, cidSupplier = randomCid, mtu = 1024)
val server = newServerDtlsTransmitter(7004)

val clientConf = SslConfig.client(trustedCerts = listOf(Certs.rootRsa.asX509()))
val clientConf = SslConfig.client(trustedCerts = listOf(Certs.rootRsa.asX509()), cipherSuites = listOf("TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256"))
val client = DtlsTransmitter.connect(srvTrans, clientConf, 7004).await()

client.send("dupa")
assertEquals("dupa", server.await().receiveString())

client.saveSession()
assertTrue(client.saveSession().isNotEmpty())
}

@Test
Expand Down

0 comments on commit a97d13c

Please sign in to comment.