tcps

Crates.iotcps
lib.rstcps
version0.1.0
sourcesrc
created_at2023-07-12 14:48:43.793392
updated_at2023-07-12 14:48:43.793392
descriptionVery lightweight wrapper to take the full advantage of rustls.
homepagehttps://docs.rs/tcps
repositoryhttps://repo.zzwxh.top
max_upload_size
id914566
size6,754
(snjauasmsk)

documentation

https://docs.rs/tcps

README

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.

Commit count: 0

cargo fmt