Skip to main content

TLS client

Creating a TLS client is exactly the same process as a TCP client, except that an extra TlsClientConfig is required. For more details about TLS support and the configuration options, check the TLS general information page.

Certificate authority-based configuration​

let config = TlsClientConfig::full_pki(
Some(domain.to_string()),
ca_cert,
entity_cert,
entity_key,
None, // no password
MinTlsVersion::V12,
)?;

let channel = spawn_master_tls_client(
LinkErrorMode::Close,
get_master_channel_config(master_address)?,
EndpointList::new(endpoint.to_string(), &[]),
ConnectStrategy::default(),
LogListener::create("client"),
config,
);

Self-signed certificate configuration​

let config = TlsClientConfig::self_signed(
peer_cert,
entity_cert,
entity_key,
None, // no password
MinTlsVersion::V12,
)?;

let channel = spawn_master_tls_client(
LinkErrorMode::Close,
get_master_channel_config(master_address)?,
EndpointList::new(endpoint.to_string(), &[]),
ConnectStrategy::default(),
LogListener::create("client"),
config,
);