Skip to content

An async tls stream library based on rustls and futures-io. Both for server/client.

License

Notifications You must be signed in to change notification settings

hs-CN/async-rustls-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

An async tls stream library based on rustls and futures-io. Both for server/client.

Server

let listener = async_net::TcpListener::bind((Ipv4Addr::LOCALHOST, 4443)).await.unwrap();
let (stream, remote_addr) = listener.accept().await.unwrap();

// Recv Client Hello
let accept = TlsAccepted::accept(stream).await.unwrap();

let server_config = Arc::new(server_config);
let mut stream = accept.into_stream(server_config.clone()).unwrap();
// handshake completed
stream.flush().await.unwrap();

Client

let server_name = "test.com".try_into().unwrap();
let client_config = Arc::new(client_config);
let connector = TlsConnector::new(client_config.clone(), server_name).unwrap();

let stream = async_net::TcpStream::connect((Ipv4Addr::LOCALHOST, 4443)).await.unwrap();

let mut stream = connector.connect(stream);
// handshake completed
stream.flush().await.unwrap();

or examples.

About

An async tls stream library based on rustls and futures-io. Both for server/client.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published