Package io.ktor.network.tls

Types

CIOCipherSuites

object CIOCipherSuites

CIO cipher suites collection https://www.ietf.org/rfc/rfc5289.txt https://tools.ietf.org/html/rfc5288#section-3

CertificateAndKey

class CertificateAndKey

Client certificate chain with private key.

CipherSuite

data class CipherSuite

Represents a TLS cipher suite

CipherType

enum class CipherType

Cipher type.

OID

data class OID

SecretExchangeType

enum class SecretExchangeType

TLS secret key exchange type.

ServerKeyExchangeType

enum class ServerKeyExchangeType

Server key exchange type with it’s code

TLSAlertLevel

enum class TLSAlertLevel

TLS alert level

TLSAlertType

enum class TLSAlertType

TLS alert types with codes

TLSConfig

expect class TLSConfig

TLSConfigBuilder

expect class TLSConfigBuilder

TLSConfig builder.

TLSHandshakeType

enum class TLSHandshakeType

TLS handshake record type

TLSRecordType

enum class TLSRecordType

TLS record type with it’s numeric code

TLSVersion

enum class TLSVersion

TLS version

Exceptions

NoPrivateKeyException

class NoPrivateKeyException : 
    IllegalStateException,
    CopyableThrowable<NoPrivateKeyException>

Throws if failed to find PrivateKey for any alias in KeyStore.

Functions

addCertificateChain

fun TLSConfigBuilder.addCertificateChain(
    chain: Array<X509Certificate>,
    key: PrivateKey
): Unit

Add client certificate chain to use.

addKeyStore

fun TLSConfigBuilder.addKeyStore(
    store: KeyStore,
    password: CharArray
): Unit

Add client certificates from store.

keysGenerationAlgorithm

fun keysGenerationAlgorithm(algorithm: String): String

takeFrom

expect fun TLSConfigBuilder.takeFrom(
    other: TLSConfigBuilder
): Unit

Append config from other builder.

tls

suspend expect fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    config: TLSConfig
): Socket

Make Socket connection secure with TLS using TLSConfig.

suspend fun Socket.tls(
    coroutineContext: <ERROR CLASS>
): Socket

Make Socket connection secure with TLS configured with block.

suspend expect fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    block: TLSConfigBuilder.() -> Unit
): Socket

Make Socket connection secure with TLS configured with block.

suspend fun Socket.tls(
    coroutineContext: <ERROR CLASS>,
    trustManager: X509TrustManager? = null,
    randomAlgorithm: String = "NativePRNGNonBlocking",
    cipherSuites: List<CipherSuite> = CIOCipherSuites.SupportedSuites,
    serverName: String? = null
): Socket

Make Socket connection secure with TLS.