Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hs-cn/async-rustls-stream
An async tls stream library based on rustls and futures-io. Both for server/client.
https://github.com/hs-cn/async-rustls-stream
async rust rustls stream tls
Last synced: about 1 month ago
JSON representation
An async tls stream library based on rustls and futures-io. Both for server/client.
- Host: GitHub
- URL: https://github.com/hs-cn/async-rustls-stream
- Owner: hs-CN
- License: mit
- Created: 2022-10-03T06:58:24.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-08T08:29:37.000Z (almost 2 years ago)
- Last Synced: 2024-04-27T02:44:00.219Z (7 months ago)
- Topics: async, rust, rustls, stream, tls
- Language: Rust
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
An async tls stream library based on [rustls](https://crates.io/crates/rustls) and [futures-io](https://crates.io/crates/futures-io). Both for server/client.
## Server
```rust
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
```rust
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](https://github.com/hs-CN/async-rustls-stream/blob/master/examples).