Move tokio-rustls to top level

pull/2/head
Dirkjan Ochtman 11 months ago
parent 0ce49fa9cd
commit b496e24270
  1. 38
      Cargo.toml
  2. 25
      LICENSE
  3. 0
      LICENSE-APACHE
  4. 0
      LICENSE-MIT
  5. 99
      README.md
  6. 0
      examples/client.rs
  7. 0
      examples/server.rs
  8. 0
      scripts/generate-certificate.sh
  9. 0
      src/client.rs
  10. 0
      src/common/handshake.rs
  11. 0
      src/common/mod.rs
  12. 0
      src/common/test_stream.rs
  13. 0
      src/lib.rs
  14. 0
      src/server.rs
  15. 0
      tests/badssl.rs
  16. 0
      tests/early-data.rs
  17. 0
      tests/end.cert
  18. 0
      tests/end.chain
  19. 0
      tests/end.rsa
  20. 0
      tests/test.rs
  21. 0
      tests/utils.rs
  22. 34
      tokio-rustls/Cargo.toml
  23. 77
      tokio-rustls/README.md

@ -1,4 +1,34 @@
[workspace]
members = [
"tokio-rustls",
]
[package]
name = "tokio-rustls"
version = "0.24.0"
authors = ["quininer kel <quininer@live.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/tokio-rs/tls"
homepage = "https://github.com/tokio-rs/tls"
documentation = "https://docs.rs/tokio-rustls"
readme = "README.md"
description = "Asynchronous TLS/SSL streams for Tokio using Rustls."
categories = ["asynchronous", "cryptography", "network-programming"]
edition = "2018"
rust-version = "1.56"
[dependencies]
tokio = "1.0"
rustls = { version = "0.21.0", default-features = false }
[features]
default = ["logging", "tls12"]
dangerous_configuration = ["rustls/dangerous_configuration"]
early-data = []
logging = ["rustls/logging"]
secret_extraction = ["rustls/secret_extraction"]
tls12 = ["rustls/tls12"]
[dev-dependencies]
argh = "0.1"
tokio = { version = "1.0", features = ["full"] }
futures-util = "0.3.1"
lazy_static = "1"
webpki-roots = "0.22"
rustls-pemfile = "1"
webpki = { package = "rustls-webpki", version = "0.100.0", features = ["alloc", "std"] }

@ -1,25 +0,0 @@
Copyright (c) 2019 Tokio Contributors
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

@ -1,66 +1,77 @@
# Tokio Tls
# tokio-rustls
[![github actions](https://github.com/tokio-rs/tls/workflows/CI/badge.svg)](https://github.com/tokio-rs/tls/actions)
[![crates](https://img.shields.io/crates/v/tokio-rustls.svg)](https://crates.io/crates/tokio-rustls)
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tokio-rs/tls/blob/master/tokio-rustls/LICENSE-MIT)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/tokio-rs/tls/blob/master/tokio-rustls/LICENSE-APACHE)
[![docs.rs](https://docs.rs/tokio-rustls/badge.svg)](https://docs.rs/tokio-rustls)
## Overview
Asynchronous TLS/SSL streams for [Tokio](https://tokio.rs/) using
[Rustls](https://github.com/rustls/rustls).
This crate contains a collection of Tokio based TLS libraries.
### Basic Structure of a Client
- [`tokio-native-tls`](tokio-native-tls)
- [`tokio-rustls`](tokio-rustls)
```rust
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName};
use tokio_rustls::TlsConnector;
## Getting Help
// ...
First, see if the answer to your question can be found in the [Tutorials] or the
[API documentation]. If the answer is not there, there is an active community in
the [Tokio Discord server][chat]. We would be happy to try to answer your
question. Last, if that doesn't work, try opening an [issue] with the question.
let mut root_cert_store = RootCertStore::empty();
root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
}));
let config = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_cert_store)
.with_no_client_auth();
let connector = TlsConnector::from(Arc::new(config));
let dnsname = ServerName::try_from("www.rust-lang.org").unwrap();
[Tutorials]: https://tokio.rs/tokio/tutorial
[API documentation]: https://docs.rs/tokio/latest/tokio
[chat]: https://discord.gg/tokio
[issue]: https://github.com/tokio-rs/tls/issues/new
let stream = TcpStream::connect(&addr).await?;
let mut stream = connector.connect(dnsname, stream).await?;
## Contributing
// ...
```
:balloon: Thanks for your help improving the project! We are so happy to have
you! We have a [contributing guide][guide] to help you get involved in the Tokio
project.
### Client Example Program
[guide]: CONTRIBUTING.md
See [examples/client](examples/client/src/main.rs). You can run it with:
## Related Projects
```sh
cd examples/client
cargo run -- hsts.badssl.com
```
In addition to the crates in this repository, the Tokio project also maintains
several other libraries, including:
### Server Example Program
* [`tokio`]: A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language.
See [examples/server](examples/server/src/main.rs). You can run it with:
* [`tracing`] (formerly `tokio-trace`): A framework for application-level
tracing and async-aware diagnostics.
```sh
cd examples/server
cargo run -- 127.0.0.1:8000 --cert mycert.der --key mykey.der
```
* [`mio`]: A low-level, cross-platform abstraction over OS I/O APIs that powers
`tokio`.
### License & Origin
* [`bytes`]: Utilities for working with bytes, including efficient byte buffers.
This project is licensed under either of
[`tokio`]: https://github.com/tokio-rs/tokio
[`tracing`]: https://github.com/tokio-rs/tracing
[`mio`]: https://github.com/tokio-rs/mio
[`bytes`]: https://github.com/tokio-rs/bytes
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
https://opensource.org/licenses/MIT)
## Supported Rust Versions
at your option.
Tokio is built against the latest stable, nightly, and beta Rust releases. The
minimum version supported is the stable release from three months before the
current stable release version. For example, if the latest stable Rust is 1.29,
the minimum version supported is 1.26. The current Tokio version is not
guaranteed to build on Rust versions earlier than the minimum supported version.
## License
This project is licensed under the [MIT license](LICENSE).
This started as a fork of [tokio-tls](https://github.com/tokio-rs/tokio-tls).
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.
for inclusion in tokio-rustls by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

@ -1,34 +0,0 @@
[package]
name = "tokio-rustls"
version = "0.24.0"
authors = ["quininer kel <quininer@live.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/tokio-rs/tls"
homepage = "https://github.com/tokio-rs/tls"
documentation = "https://docs.rs/tokio-rustls"
readme = "README.md"
description = "Asynchronous TLS/SSL streams for Tokio using Rustls."
categories = ["asynchronous", "cryptography", "network-programming"]
edition = "2018"
rust-version = "1.56"
[dependencies]
tokio = "1.0"
rustls = { version = "0.21.0", default-features = false }
[features]
default = ["logging", "tls12"]
dangerous_configuration = ["rustls/dangerous_configuration"]
early-data = []
logging = ["rustls/logging"]
secret_extraction = ["rustls/secret_extraction"]
tls12 = ["rustls/tls12"]
[dev-dependencies]
argh = "0.1"
tokio = { version = "1.0", features = ["full"] }
futures-util = "0.3.1"
lazy_static = "1"
webpki-roots = "0.22"
rustls-pemfile = "1"
webpki = { package = "rustls-webpki", version = "0.100.0", features = ["alloc", "std"] }

@ -1,77 +0,0 @@
# tokio-rustls
[![github actions](https://github.com/tokio-rs/tls/workflows/CI/badge.svg)](https://github.com/tokio-rs/tls/actions)
[![crates](https://img.shields.io/crates/v/tokio-rustls.svg)](https://crates.io/crates/tokio-rustls)
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tokio-rs/tls/blob/master/tokio-rustls/LICENSE-MIT)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/tokio-rs/tls/blob/master/tokio-rustls/LICENSE-APACHE)
[![docs.rs](https://docs.rs/tokio-rustls/badge.svg)](https://docs.rs/tokio-rustls)
Asynchronous TLS/SSL streams for [Tokio](https://tokio.rs/) using
[Rustls](https://github.com/rustls/rustls).
### Basic Structure of a Client
```rust
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName};
use tokio_rustls::TlsConnector;
// ...
let mut root_cert_store = RootCertStore::empty();
root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
}));
let config = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_cert_store)
.with_no_client_auth();
let connector = TlsConnector::from(Arc::new(config));
let dnsname = ServerName::try_from("www.rust-lang.org").unwrap();
let stream = TcpStream::connect(&addr).await?;
let mut stream = connector.connect(dnsname, stream).await?;
// ...
```
### Client Example Program
See [examples/client](examples/client/src/main.rs). You can run it with:
```sh
cd examples/client
cargo run -- hsts.badssl.com
```
### Server Example Program
See [examples/server](examples/server/src/main.rs). You can run it with:
```sh
cd examples/server
cargo run -- 127.0.0.1:8000 --cert mycert.der --key mykey.der
```
### License & Origin
This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
https://opensource.org/licenses/MIT)
at your option.
This started as a fork of [tokio-tls](https://github.com/tokio-rs/tokio-tls).
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in tokio-rustls by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
Loading…
Cancel
Save