async-native-tls 0.1.1

Native TLS using futures
Documentation

async-native-tls

TLS implementation for asnync. Based on tokio-tls.

Installation

$ cargo add async-native-tls

Example

// First up, resolve google.com
let addr = "google.com:443".to_socket_addrs().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 = async_native_tls::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.read_to_end(&mut data).await.unwrap();

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

let data = String::from_utf8_lossy(&data);
let data = data.trim_end();
assert!(data.ends_with("</html>") || data.ends_with("</HTML>"));

Contributing

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

License