9个不稳定版本

0.5.0 2023年3月2日
0.4.0 2021年11月12日
0.3.3 2020年3月9日
0.3.2 2020年1月12日
0.1.1 2019年12月12日

#28 in 异步

Download history 30965/week @ 2024-03-14 36914/week @ 2024-03-21 30868/week @ 2024-03-28 37399/week @ 2024-04-04 25916/week @ 2024-04-11 31923/week @ 2024-04-18 36183/week @ 2024-04-25 31429/week @ 2024-05-02 29640/week @ 2024-05-09 26054/week @ 2024-05-16 29366/week @ 2024-05-23 30948/week @ 2024-05-30 25487/week @ 2024-06-06 30545/week @ 2024-06-13 29317/week @ 2024-06-20 23318/week @ 2024-06-27

113,777次每月下载
188个crate中使用 (直接使用54个)

MIT/Apache

36KB
571

async-native-tls

异步本地TLS


Native TLS for async-stdtokio.

此crate在Windows上使用SChannel (通过 schannel),在OSX上使用Secure Transport (通过 security-framework),在其他所有平台上使用OpenSSL (通过 openssl)。

安装

$ cargo add async-native-tls

Cargo功能标志

  • runtime-async-std (默认开启): 使用 async-std 运行时。

  • runtime-tokio: 使用 tokio 运行时。此选项与 runtime-async-std 互斥。

示例

async-std

需要 runtime-async-std 功能 (默认开启)。

# 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

需要 runtime-tokio 功能。

# 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));

贡献

想要加入我们?请查看我们的"贡献"指南并查看一些这些问题

许可协议

许可协议为Apache License, Version 2.0MIT许可协议,由您选择。
除非您明确声明,否则您有意提交给此crate的任何贡献,根据Apache-2.0许可协议定义,都将按照上述方式双许可,不附加任何额外的条款或条件。

依赖关系

~1–13MB
~182K SLoC