Crates.io | async-native-tls |
lib.rs | async-native-tls |
version | 0.5.0 |
source | src |
created_at | 2019-12-12 17:20:21.373661 |
updated_at | 2023-03-02 01:14:48.486539 |
description | Native TLS using futures |
homepage | https://docs.rs/crate/async-native-tls/ |
repository | https://github.com/async-email/async-native-tls |
max_upload_size | |
id | 188826 |
size | 79,604 |
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.
$ cargo add async-native-tls
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
.
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));
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));
Want to join us? Check out our "Contributing" guide and take a look at some of these issues: