| 1 | <h1 align="center">async-tls</h1> |
| 2 | <div align="center"> |
| 3 | <strong> |
| 4 | Async TLS/SSL streams using <a href="https://github.com/ctz/rustls">Rustls</a>. |
| 5 | </strong> |
| 6 | </div> |
| 7 | |
| 8 | <br /> |
| 9 | |
| 10 | <div align="center"> |
| 11 | <!-- Crates version --> |
| 12 | <a href="https://crates.io/crates/async-tls"> |
| 13 | <img src="https://img.shields.io/crates/v/async-tls.svg?style=flat-square" |
| 14 | alt="Crates.io version" /> |
| 15 | </a> |
| 16 | <!-- Downloads --> |
| 17 | <a href="https://crates.io/crates/async-tls"> |
| 18 | <img src="https://img.shields.io/crates/d/async-tls.svg?style=flat-square" |
| 19 | alt="Download" /> |
| 20 | </a> |
| 21 | <!-- docs.rs docs --> |
| 22 | <a href="https://docs.rs/async-tls"> |
| 23 | <img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" |
| 24 | alt="docs.rs docs" /> |
| 25 | </a> |
| 26 | |
| 27 | <a href="https://discord.gg/JvZeVNe"> |
| 28 | <img src="https://img.shields.io/discord/598880689856970762.svg?logo=discord&style=flat-square" |
| 29 | alt="chat" /> |
| 30 | </a> |
| 31 | </div> |
| 32 | |
| 33 | <div align="center"> |
| 34 | <h3> |
| 35 | <a href="https://docs.rs/async-tls"> |
| 36 | API Docs |
| 37 | </a> |
| 38 | <span> | </span> |
| 39 | <a href="https://github.com/async-rs/async-tls/releases"> |
| 40 | Releases |
| 41 | </a> |
| 42 | <span> | </span> |
| 43 | <a href="https://async.rs/contribute"> |
| 44 | Contributing |
| 45 | </a> |
| 46 | </h3> |
| 47 | </div> |
| 48 | |
| 49 | <br/> |
| 50 | |
| 51 | # Maintenance Notice |
| 52 | |
| 53 | I, [Florian Gilcher](https://github.com/skade), am currently the main maintainer of `async-tls`. Due to general workload, I would like the hand the maintenance off to someone else carrying the general vision of `async-tls`: |
| 54 | |
| 55 | * Runtime-independence |
| 56 | * Backend-independence (currently not implemented) |
| 57 | * Focused on _use-case based_ configuration rather then exposing all configurations |
| 58 | |
| 59 | I expect applicants for maintainership to present a committment of at least 4h of time/week initially, so I recommend getting corporate backing first. The number isn't strict, but I want the process to improve maintenance. I'm happy with a group of multiple maintainers. |
| 60 | |
| 61 | I commit to weekly feedback of 30 minutes for the first 2 months - more in the initial days of handover. |
| 62 | |
| 63 | If interested, please reach out to me at [through email](mailto:[email protected]). |
| 64 | |
| 65 | # Features |
| 66 | |
| 67 | `async-tls` can be used both in server and client programs. To save compilation times, you |
| 68 | can switch off parts of this for faster compile times. |
| 69 | |
| 70 | To only use async-tls on a client, deactivate default features and use the "client" feature. |
| 71 | |
| 72 | ```toml |
| 73 | [dependencies.async-tls] |
| 74 | version = "0.8" |
| 75 | default-features = false |
| 76 | features = ["client"] |
| 77 | ``` |
| 78 | |
| 79 | To only use async-tls on for the server side, deactivate default features and use the "server" feature. |
| 80 | |
| 81 | ```toml |
| 82 | [dependencies.async-tls] |
| 83 | version = "0.8" |
| 84 | default-features = false |
| 85 | features = ["server"] |
| 86 | ``` |
| 87 | |
| 88 | ### Simple Client |
| 89 | |
| 90 | ```rust |
| 91 | use async_tls::TlsConnector; |
| 92 | use async_std::net::TcpStream; |
| 93 | |
| 94 | // ... |
| 95 | |
| 96 | let tcp_stream = TcpStream::connect("rust-lang.org:443").await?; |
| 97 | let connector = TlsConnector::default(); |
| 98 | let mut tls_stream = connector.connect("www.rust-lang.org", tcp_stream).await?; |
| 99 | |
| 100 | // ... |
| 101 | ``` |
| 102 | |
| 103 | ### Client Example Program |
| 104 | |
| 105 | See [examples/client](examples/client/src/main.rs). You can run it with: |
| 106 | |
| 107 | ```sh |
| 108 | cd examples/client |
| 109 | cargo run -- hsts.badssl.com |
| 110 | ``` |
| 111 | |
| 112 | ### Server Example Program |
| 113 | |
| 114 | See [examples/server](examples/server/src/main.rs). You can run it with: |
| 115 | |
| 116 | ```sh |
| 117 | cd examples/server |
| 118 | cargo run -- 127.0.0.1:8080 --cert ../../tests/end.cert --key ../../tests/end.rsa |
| 119 | ``` |
| 120 | |
| 121 | and point the client at it with: |
| 122 | |
| 123 | ```sh |
| 124 | cd examples/client |
| 125 | cargo run -- 127.0.0.1 --port 8080 --domain localhost --cafile ../../tests/end.chain |
| 126 | ``` |
| 127 | |
| 128 | **NOTE**: Don't ever use those certificate files anywhere but for testing! |
| 129 | |
| 130 | ## Safety |
| 131 | |
| 132 | This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in |
| 133 | 100% Safe Rust. |
| 134 | |
| 135 | ### License & Origin |
| 136 | |
| 137 | This project is licensed under either of |
| 138 | |
| 139 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or |
| 140 | http://www.apache.org/licenses/LICENSE-2.0) |
| 141 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or |
| 142 | http://opensource.org/licenses/MIT) |
| 143 | |
| 144 | at your option. |
| 145 | |
| 146 | This started as a fork of [tokio-rustls](https://github.com/quininer/tokio-rustls). |
| 147 | |
| 148 | ### Contribution |
| 149 | |
| 150 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 151 | for inclusion in async-tls by you, as defined in the Apache-2.0 license, shall be |
| 152 | dual licensed as above, without any additional terms or conditions. |