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.

Examples

Certificate Authority-based configuration

let config = TlsClientConfig::new(
"test.com",
&Path::new("./certs/ca_chain/ca_cert.pem"),
&Path::new("./certs/ca_chain/entity1_cert.pem"),
&Path::new("./certs/ca_chain/entity1_key.pem"),
None, // no password
MinTlsVersion::V12,
CertificateMode::AuthorityBased,
)?;

let channel = spawn_master_tls_client(
LinkErrorMode::Close,
get_master_channel_config()?,
EndpointList::new("127.0.0.1:20001".to_owned(), &[]),
ConnectStrategy::default(),
NullListener::create(),
tls_config,
);

Self-signed certificate configuration

let config = TlsClientConfig::new(
"test.com",
&Path::new("./certs/self_signed/entity2_cert.pem"),
&Path::new("./certs/self_signed/entity1_cert.pem"),
&Path::new("./certs/self_signed/entity1_key.pem"),
None, // no password
MinTlsVersion::V12,
CertificateMode::SelfSigned,
)?;

let channel = spawn_master_tls_client(
LinkErrorMode::Close,
get_master_channel_config()?,
EndpointList::new("127.0.0.1:20001".to_owned(), &[]),
ConnectStrategy::default(),
NullListener::create(),
tls_config,
);