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.

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

class TLSConfig

TLS configuration.

TLSConfigBuilder

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

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.

tls

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

Make Socket connection secure with TLS using TLSConfig.

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.

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

Make Socket connection secure with TLS configured with block.