9 unstable releases

0.5.0 Mar 2, 2023
0.4.0 Nov 12, 2021
0.3.3 Mar 9, 2020
0.3.2 Jan 12, 2020
0.1.1 Dec 12, 2019

#36 in Asynchronous

Download history 30887/week @ 2023-12-14 21691/week @ 2023-12-21 16469/week @ 2023-12-28 26540/week @ 2024-01-04 32223/week @ 2024-01-11 37317/week @ 2024-01-18 30970/week @ 2024-01-25 31911/week @ 2024-02-01 43795/week @ 2024-02-08 27040/week @ 2024-02-15 23226/week @ 2024-02-22 25380/week @ 2024-02-29 26760/week @ 2024-03-07 30965/week @ 2024-03-14 36930/week @ 2024-03-21 22182/week @ 2024-03-28

121,261 downloads per month
Used in 181 crates (52 directly)

MIT/Apache

36KB
571 lines

async-native-tls

Asynchronous Native TLS


Native TLS for async-std or tokio.

This crate uses SChannel on Windows (via schannel), Secure Transport on OSX (via security-framework), and OpenSSL (via openssl) on all other platforms.

Installation

$ cargo add async-native-tls

Cargo Feature Flags

  • runtime-async-std (on by default): Use the async-std runtime.

  • runtime-tokio: Use the tokio runtime. This is mutually exclusive with runtime-async-std.

Example

async-std

Requires runtime-async-std feature (on by default).

# Cargo.toml
[dependencies]
async-native-tls = "0.4"
use async_std::prelude::*;
use async_std::net::TcpStream;

let stream = TcpStream::connect("google.com:443").await?;
let mut stream = async_native_tls::connect("google.com", stream).await?;
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await?;

let mut res = Vec::new();
stream.read_to_end(&mut res).await?;
println!("{}", String::from_utf8_lossy(&res));

tokio

Requires runtime-tokio feature.

# Cargo.toml
[dependencies]
async-native-tls = { version = "0.4", default-features = false, features = [ "runtime-tokio" ] }
use tokio::prelude::*;
use tokio::net::TcpStream;

let stream = TcpStream::connect("google.com:443").await?;
let mut stream = async_native_tls::connect("google.com", stream).await?;
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await?;

let mut res = Vec::new();
stream.read_to_end(&mut res).await?;
println!("{}", String::from_utf8_lossy(&res));

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.

Dependencies

~2–14MB
~200K SLoC