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 异步
113,777次每月下载
在188个crate中使用 (直接使用54个)
36KB
571 行
async-native-tls
异步本地TLS
Native TLS for async-std 或 tokio.
此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.0或MIT许可协议,由您选择。除非您明确声明,否则您有意提交给此crate的任何贡献,根据Apache-2.0许可协议定义,都将按照上述方式双许可,不附加任何额外的条款或条件。
依赖关系
~1–13MB
~182K SLoC