From b496e24270bf260e69acf1a4707d3e07997f3050 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 31 May 2023 09:17:08 +0200 Subject: [PATCH] Move tokio-rustls to top level --- Cargo.toml | 38 ++++++- LICENSE | 25 ----- tokio-rustls/LICENSE-APACHE => LICENSE-APACHE | 0 tokio-rustls/LICENSE-MIT => LICENSE-MIT | 0 README.md | 99 ++++++++++--------- {tokio-rustls/examples => examples}/client.rs | 0 {tokio-rustls/examples => examples}/server.rs | 0 .../generate-certificate.sh | 0 {tokio-rustls/src => src}/client.rs | 0 {tokio-rustls/src => src}/common/handshake.rs | 0 {tokio-rustls/src => src}/common/mod.rs | 0 .../src => src}/common/test_stream.rs | 0 {tokio-rustls/src => src}/lib.rs | 0 {tokio-rustls/src => src}/server.rs | 0 {tokio-rustls/tests => tests}/badssl.rs | 0 {tokio-rustls/tests => tests}/early-data.rs | 0 {tokio-rustls/tests => tests}/end.cert | 0 {tokio-rustls/tests => tests}/end.chain | 0 {tokio-rustls/tests => tests}/end.rsa | 0 {tokio-rustls/tests => tests}/test.rs | 0 {tokio-rustls/tests => tests}/utils.rs | 0 tokio-rustls/Cargo.toml | 34 ------- tokio-rustls/README.md | 77 --------------- 23 files changed, 89 insertions(+), 184 deletions(-) delete mode 100644 LICENSE rename tokio-rustls/LICENSE-APACHE => LICENSE-APACHE (100%) rename tokio-rustls/LICENSE-MIT => LICENSE-MIT (100%) rename {tokio-rustls/examples => examples}/client.rs (100%) rename {tokio-rustls/examples => examples}/server.rs (100%) rename {tokio-rustls/scripts => scripts}/generate-certificate.sh (100%) rename {tokio-rustls/src => src}/client.rs (100%) rename {tokio-rustls/src => src}/common/handshake.rs (100%) rename {tokio-rustls/src => src}/common/mod.rs (100%) rename {tokio-rustls/src => src}/common/test_stream.rs (100%) rename {tokio-rustls/src => src}/lib.rs (100%) rename {tokio-rustls/src => src}/server.rs (100%) rename {tokio-rustls/tests => tests}/badssl.rs (100%) rename {tokio-rustls/tests => tests}/early-data.rs (100%) rename {tokio-rustls/tests => tests}/end.cert (100%) rename {tokio-rustls/tests => tests}/end.chain (100%) rename {tokio-rustls/tests => tests}/end.rsa (100%) rename {tokio-rustls/tests => tests}/test.rs (100%) rename {tokio-rustls/tests => tests}/utils.rs (100%) delete mode 100644 tokio-rustls/Cargo.toml delete mode 100644 tokio-rustls/README.md diff --git a/Cargo.toml b/Cargo.toml index 661eb66..d116d22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,34 @@ -[workspace] -members = [ - "tokio-rustls", -] +[package] +name = "tokio-rustls" +version = "0.24.0" +authors = ["quininer kel "] +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"] } diff --git a/LICENSE b/LICENSE deleted file mode 100644 index cdb28b4..0000000 --- a/LICENSE +++ /dev/null @@ -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. diff --git a/tokio-rustls/LICENSE-APACHE b/LICENSE-APACHE similarity index 100% rename from tokio-rustls/LICENSE-APACHE rename to LICENSE-APACHE diff --git a/tokio-rustls/LICENSE-MIT b/LICENSE-MIT similarity index 100% rename from tokio-rustls/LICENSE-MIT rename to LICENSE-MIT diff --git a/README.md b/README.md index e4dff21..87d226f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tokio-rustls/examples/client.rs b/examples/client.rs similarity index 100% rename from tokio-rustls/examples/client.rs rename to examples/client.rs diff --git a/tokio-rustls/examples/server.rs b/examples/server.rs similarity index 100% rename from tokio-rustls/examples/server.rs rename to examples/server.rs diff --git a/tokio-rustls/scripts/generate-certificate.sh b/scripts/generate-certificate.sh similarity index 100% rename from tokio-rustls/scripts/generate-certificate.sh rename to scripts/generate-certificate.sh diff --git a/tokio-rustls/src/client.rs b/src/client.rs similarity index 100% rename from tokio-rustls/src/client.rs rename to src/client.rs diff --git a/tokio-rustls/src/common/handshake.rs b/src/common/handshake.rs similarity index 100% rename from tokio-rustls/src/common/handshake.rs rename to src/common/handshake.rs diff --git a/tokio-rustls/src/common/mod.rs b/src/common/mod.rs similarity index 100% rename from tokio-rustls/src/common/mod.rs rename to src/common/mod.rs diff --git a/tokio-rustls/src/common/test_stream.rs b/src/common/test_stream.rs similarity index 100% rename from tokio-rustls/src/common/test_stream.rs rename to src/common/test_stream.rs diff --git a/tokio-rustls/src/lib.rs b/src/lib.rs similarity index 100% rename from tokio-rustls/src/lib.rs rename to src/lib.rs diff --git a/tokio-rustls/src/server.rs b/src/server.rs similarity index 100% rename from tokio-rustls/src/server.rs rename to src/server.rs diff --git a/tokio-rustls/tests/badssl.rs b/tests/badssl.rs similarity index 100% rename from tokio-rustls/tests/badssl.rs rename to tests/badssl.rs diff --git a/tokio-rustls/tests/early-data.rs b/tests/early-data.rs similarity index 100% rename from tokio-rustls/tests/early-data.rs rename to tests/early-data.rs diff --git a/tokio-rustls/tests/end.cert b/tests/end.cert similarity index 100% rename from tokio-rustls/tests/end.cert rename to tests/end.cert diff --git a/tokio-rustls/tests/end.chain b/tests/end.chain similarity index 100% rename from tokio-rustls/tests/end.chain rename to tests/end.chain diff --git a/tokio-rustls/tests/end.rsa b/tests/end.rsa similarity index 100% rename from tokio-rustls/tests/end.rsa rename to tests/end.rsa diff --git a/tokio-rustls/tests/test.rs b/tests/test.rs similarity index 100% rename from tokio-rustls/tests/test.rs rename to tests/test.rs diff --git a/tokio-rustls/tests/utils.rs b/tests/utils.rs similarity index 100% rename from tokio-rustls/tests/utils.rs rename to tests/utils.rs diff --git a/tokio-rustls/Cargo.toml b/tokio-rustls/Cargo.toml deleted file mode 100644 index d116d22..0000000 --- a/tokio-rustls/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "tokio-rustls" -version = "0.24.0" -authors = ["quininer kel "] -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"] } diff --git a/tokio-rustls/README.md b/tokio-rustls/README.md deleted file mode 100644 index 87d226f..0000000 --- a/tokio-rustls/README.md +++ /dev/null @@ -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.