std.net.tls.ClientConfig
type pub ClientConfigA 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 codeHide source code
fn pub static new -> Option[ClientConfig] {
match inko_tls_client_config_new {
case { @tag = OK, @value = v } -> {
Option.Some(ClientConfig(v as Pointer[UInt8]))
}
case _ -> Option.None
}
}fn pub static new -> Option[ClientConfig]Returns a new ClientConfig that uses the system's certificate store.
If the system's TLS configuration can't be loaded, an Option.None is
returned.
Examples
import std.net.tls (ClientConfig)
ClientConfig.new.some? # => true
with_certificate
Show source codeHide source code
fn pub static with_certificate(
certificate: ref Certificate,
) -> Option[ClientConfig] {
match
inko_tls_client_config_with_certificate(
certificate.bytes.pointer,
certificate.bytes.size,
)
{
case { @tag = OK, @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_with('the client configuration is invalid')
Instance methods
clone
Show source codeHide source code
fn pub clone -> ClientConfig {
ClientConfig(inko_tls_client_config_clone(@raw))
}fn pub clone -> ClientConfigCreates a clone of self.
The returned value is an owned value that is the same type as the receiver
of this method. For example, cloning a ref Array[Int] results in a
Array[Int], not another ref Array[Int].
Implemented traits
Clone
impl Clone for ClientConfigDrop
impl Drop for ClientConfig