async-native-tls

TLS implementation for asnync. Based on tokio-tls.

Installation

sh $ cargo add async-native-tls

Example

```rust // First up, resolve google.com let addr = "google.com:443".tosocketaddrs().unwrap().next().unwrap();

let socket = TcpStream::connect(&addr).await.unwrap();

// Send off the request by first negotiating an SSL handshake, then writing // of our request, then flushing, then finally read off the response. let builder = TlsConnector::builder(); let connector = builder.build().unwrap(); let connector = asyncnativetls::TlsConnector::from(connector); let mut socket = connector.connect("google.com", socket).await; socket.write_all(b"GET / HTTP/1.0\r\n\r\n").await.unwrap();

let mut data = Vec::new(); socket.readtoend(&mut data).await.unwrap();

// any response code is fine assert!(data.starts_with(b"HTTP/1.0 "));

let data = String::fromutf8lossy(&data); let data = data.trimend(); assert!(data.endswith("") || data.ends_with("")); ```

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.