1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<h1 align="center">async-native-tls</h1>
<div align="center">
<strong>
Asynchronous Native TLS
</strong>
</div>
<br />
<div align="center">
<!-- Crates version -->
<a href="https://crates.io/crates/async-native-tls">
<img src="https://img.shields.io/crates/v/async-native-tls.svg?style=flat-square"
alt="Crates.io version" />
</a>
<!-- Downloads -->
<a href="https://crates.io/crates/async-native-tls">
<img src="https://img.shields.io/crates/d/async-native-tls.svg?style=flat-square"
alt="Download" />
</a>
<!-- docs.rs docs -->
<a href="https://docs.rs/async-native-tls">
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
alt="docs.rs docs" />
</a>
</div>
<div align="center">
<h3>
<a href="https://docs.rs/async-native-tls">
API Docs
</a>
<span> | </span>
<a href="https://github.com/async-email/async-native-tls/releases">
Releases
</a>
</h3>
</div>
<br/>
> [Native TLS](https://crates.io/crates/native-tls) for [async-std](https://crates.io/crates/async-std) or [tokio](https://crates.io/crates/tokio).
This crate uses SChannel on Windows (via [schannel](https://crates.io/crates/schannel)), Secure Transport on
OSX (via [security-framework](https://crates.io/crates/security-framework)), and OpenSSL (via [openssl](https://crates.io/crates/openssl)) on
all other platforms.
## Installation
```sh
$ 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).
```toml
# Cargo.toml
[dependencies]
async-native-tls = "0.4"
```
```rust
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.
```toml
# Cargo.toml
[dependencies]
async-native-tls = { version = "0.4", default-features = false, features = [ "runtime-tokio" ] }
```
```rust
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][contributing] and take a
look at some of these issues:
- [Issues labeled "good first issue"][good-first-issue]
- [Issues labeled "help wanted"][help-wanted]
[contributing]: https://github.com/dignifiedquire/semver2/blob/master.github/CONTRIBUTING.md
[good-first-issue]: https://github.com/dignifiedquire/semver2/labels/good%20first%20issue
[help-wanted]: https://github.com/dignifiedquire/semver2/labels/help%20wanted
## License
<sup>
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
</sup>
<br/>
<sub>
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.
</sub>
|