Tokio TLS Helper
This code is modified and derived from tonic. It reduces the complexity of using TLS for your tokio TCP applications.
Usage:
Server:
// you could also build your config with cert and identity separately. See tests.
let config: ServerTlsConfig = from_str.unwrap;
let acceptor = config.tls_acceptor.unwrap;
let listener = bind.await.unwrap;
spawn;
Client:
let msg = b"Hello world\n";
let mut buf = ;
// you could also build your config with cert and identity separately. See tests.
let config: ClientTlsConfig = from_str.unwrap;
let connector = config.tls_connector.unwrap;
let stream = connect.await.unwrap;
let mut stream = connector.connect.await.unwrap;
info!;
stream.write_all.await.unwrap;
info!;
let = split;
reader.read_exact.await.unwrap;
info!;
Note TLS is one of many choices to secure your TCP connections, you may also consider snow which implemented Noise protocol.
License
tokio-tls-helper
is distributed under the terms of MIT.
See LICENSE for details.
Copyright 2021 Tyr Chen