Search results

There are no results.

std.net.tls.ClientConfig

class pub ClientConfig

A type storing the configuration details for TLS clients.

To configure a Server, use ServerConfig instead.

Creating a ClientConfig is potentially expensive, depending on the amount of certificates that need to be processed. As such, it's recommended to only create a ClientConfig once and use ClientConfig.clone to clone it whenever necessary (e.g. when sharing a ClientConfig between processes), as cloning a ClientConfig is cheap.

Static methods

new

Show source code
Hide source code
fn pub static new -> ClientConfig {
  ClientConfig(inko_tls_client_config_new)
}
fn pub static new -> ClientConfig

Returns a new ClientConfig that uses the system's certificate store.

Examples

import std.net.tls (ClientConfig)

ClientConfig.new

with_certificate

Show source code
Hide source code
fn pub static with_certificate(
  certificate: ref Certificate,
) -> Option[ClientConfig] {
  match inko_tls_client_config_with_certificate(certificate.bytes) {
    case { @tag = 0, @value = v } -> {
      Option.Some(ClientConfig(v as Pointer[UInt8]))
    }
    case _ -> Option.None
  }
}
fn pub static with_certificate(certificate: ref Certificate) -> Option[ClientConfig]

Returns a new ClientConfig using the specified PEM encoded X.509 certificate.

Errors

If the certificate isn't valid, a None is returned.

Examples

import std.net.tls (ClientConfig)
import std.crypto.x509 (Certificate)

# In a real program you'd load the certificate from a file or a database.
let cert = Certificate.new(ByteArray.from_array[1, 2, 3, 4])

ClientConfig
  .with_certificate(cert)
  .or_panic('the client configuration is invalid')

Instance methods

clone

Show source code
Hide source code
fn pub clone -> ClientConfig {
  ClientConfig(inko_tls_client_config_clone(@raw))
}
fn pub clone -> ClientConfig

Creates a clone of self.

Implemented traits

std.clone.

Clone

impl Clone[ClientConfig] for ClientConfig
std.drop.

Drop

impl Drop for ClientConfig