#rustls #advantage #server #client #tcp-stream #encryption #pem

yanked tcps

Very lightweight wrapper to take the full advantage of rustls

1 unstable release

0.1.0 Jul 12, 2023

#3 in #advantage

MIT/Apache

7KB
116 lines

Tcps

  • Encrypted tcp stream.
  • Support server and client.
  • Very lightweight.
  • Take the full advantage of rustls.
  • Out of the box.

Usage:

let stream = accept(...); // Create a std::net::TcpStream.
let config = tcps::server_config_from_pem_file(cert,key,ca); // Create tls config.
let encrypted = tcps::server_wrapper(stream,config); // Create a encrypted stream.
encrypted.write_all(...) // We're using mTLS now.

Api:

fn server_wrapper(
    tcp: TcpStream,
    config: Arc<ServerConfig>,
) -> StreamOwned<ServerConnection, TcpStream>;

Turn an exiting std::net::TcpStream to rustls::StreamOwned<...>

fn server_config_from_pem_file(
    cert: Vec<u8>, 
    key: Vec<u8>, 
    ca: Vec<u8>
) -> Arc<ServerConfig>;

Create rustls::ServerConfig from pem files.

Dependencies

~7–15MB
~276K SLoC