Crates.io | tcps |
lib.rs | tcps |
version | 0.1.0 |
source | src |
created_at | 2023-07-12 14:48:43.793392 |
updated_at | 2023-07-12 14:48:43.793392 |
description | Very lightweight wrapper to take the full advantage of rustls. |
homepage | https://docs.rs/tcps |
repository | https://repo.zzwxh.top |
max_upload_size | |
id | 914566 |
size | 6,754 |
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.