Skip to content

Update env_logger dependency #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ Cargo.lock

**/*.iml
.idea
.code
.vscode
.envrc

.*.swp
.direnv/
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ members = [
"test-cert-gen",
]

[workspace.package]
version = "0.12.0"
authors = ["Stepan Koltsov <stepan.koltsov@gmail.com>", "Aljaž Mur Eržen <aljaz@edgedb.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/edgedb/rust-tls-api/"
edition = "2018"
keywords = ["tls"]

[patch.crates-io]
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/stepancheg/rust-tls-api/CI)](https://github.com/stepancheg/rust-tls-api/actions?query=workflow%3ACI)
[![License](https://img.shields.io/crates/l/tls-api.svg)](https://github.com/stepancheg/rust-tls-api/blob/master/LICENSE)
[![crates.io](https://img.shields.io/crates/v/tls-api.svg)](https://crates.io/crates/tls-api)

# One TLS API to rule them all

Supports:
Expand Down Expand Up @@ -35,7 +31,7 @@ Supports:

## Example

[download-rust-lang-org.rs](https://github.com/stepancheg/rust-tls-api/blob/master/examples/examples/download-rust-lang-org.rs#L66)
[download-rust-lang-org.rs](https://github.com/edgedb/rust-tls-api/blob/master/examples/examples/download-rust-lang-org.rs#L66)
contains the implementation of simple TLS client downloading rust-lang.org,
which is invoked with four backends.

Expand Down Expand Up @@ -72,3 +68,10 @@ which is invoked with four backends.

* only works on Apple
* does not support server side ALPN


## Crate maintenance

This set of crates is currently maintained by the team of EdgeDB.
It has initially been written by

27 changes: 12 additions & 15 deletions api-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
[package]
name = "tls-api-test"
version = "0.10.0-pre"
authors = ["Stepan Koltsov <stepan.koltsov@gmail.com>"]
name = "tls-api-test-2"
description = "TLS API without implementation"
license = "MIT/Apache-2.0"
repository = "https://github.com/stepancheg/rust-tls-api/"
keywords = ["tls"]
edition = "2018"

version = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
keywords = { workspace = true }

[lib]
bench = false

[badges]
travis-ci = { repository = "https://github.com/stepancheg/rust-tls-api/", branch = "master" }

[dependencies]
tls-api = { path = "../api", version = "=0.10.0-pre", default-features = false }
tls-api = { path = "../api", version = "0.12.0", default-features = false }
log = "0.4"
env_logger = "0.5"
env_logger = "0.11.2"
anyhow = "1.0.44"

pem = "0.8.3"
pem = "3.0.4"
webpki = "0.22.0"
untrusted = "0.6.*"

tokio = { version = "1.2.0", features = ["net", "io-util", "rt", "rt-multi-thread"], optional = true }
async-std = { version = "1.9.0", features = ["attributes"], optional = true }

test-cert-gen = { path = "../test-cert-gen", version = "=0.10.0-pre", default-features = false }
test-cert-gen = { path = "../test-cert-gen", package = "test-cert-gen-2", version = "0.12.0", default-features = false }

[features]
default = ["runtime-tokio"]
Expand Down
4 changes: 0 additions & 4 deletions api-test/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/stepancheg/rust-tls-api/CI)](https://github.com/stepancheg/rust-tls-api/actions?query=workflow%3ACI)
[![License](https://img.shields.io/crates/l/tls-api.svg)](https://github.com/stepancheg/rust-tls-api/blob/master/LICENSE)
[![crates.io](https://img.shields.io/crates/v/tls-api.svg)](https://crates.io/crates/tls-api)

# tls-api-test

Test implementation the all tls-api implementations.
Expand Down
16 changes: 1 addition & 15 deletions api-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ use std::env;
use std::io::Read;
use std::process;

// % rustc +stable --version
// rustc 1.26.0 (a77568041 2018-05-07)
// % rustc +beta --version
// rustc 1.27.0-beta.1 (03fb2f447 2018-05-09)
// % rustc +nightly --version
// rustc 1.27.0-nightly (acd3871ba 2018-05-10)
fn version_is_nightly(version: &str) -> bool {
version.contains("nightly")
}

fn export_rustc_cfg() {
let rustc = env::var("RUSTC").expect("RUSTC unset");

let mut child = process::Command::new(rustc)
.args(&["--version"])
.args(["--version"])
.stdin(process::Stdio::null())
.stdout(process::Stdio::piped())
.spawn()
Expand All @@ -31,10 +21,6 @@ fn export_rustc_cfg() {
.read_to_string(&mut rustc_version)
.expect("read_to_string");
assert!(child.wait().expect("wait").success());

if version_is_nightly(&rustc_version) {
println!("cargo:rustc-cfg=rustc_nightly");
}
}

fn main() {
Expand Down
6 changes: 6 additions & 0 deletions api-test/src/alpn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ where
assert_eq!(&buf, b"hello");

t!(socket.write_all(b"world").await);

#[cfg(feature = "runtime-tokio")]
t!(socket.shutdown().await);

#[cfg(feature = "runtime-async-std")]
t!(socket.close().await);
};
block_on(f);
});
Expand Down
2 changes: 1 addition & 1 deletion api-test/src/benches.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(rustc_nightly, feature = "runtime-tokio"))]
#![cfg(feature = "runtime-tokio")]

use std::thread;

Expand Down
6 changes: 6 additions & 0 deletions api-test/src/client_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ where
assert_eq!(&buf, b"hello");

t!(socket.write_all(b"world").await);

#[cfg(feature = "runtime-tokio")]
t!(socket.shutdown().await);

#[cfg(feature = "runtime-async-std")]
t!(socket.close().await);
};
block_on(future);
})
Expand Down
6 changes: 6 additions & 0 deletions api-test/src/client_server_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ async fn test_client_server_dyn_impl(
assert_eq!(&buf, b"hello");

t!(socket.write_all(b"world").await);

#[cfg(feature = "runtime-tokio")]
t!(socket.shutdown().await);

#[cfg(feature = "runtime-async-std")]
t!(socket.close().await);
};
block_on(future);
})
Expand Down
4 changes: 1 addition & 3 deletions api-test/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn bench_1_dyn(b: &mut test::Bencher) {

/// Called from impl crates to generate the common set of tests
pub fn gen_tests_and_benches() {
let crate_name = env::var("CARGO_PKG_NAME").unwrap().replace("-", "_");
let crate_name = env::var("CARGO_PKG_NAME").unwrap().replace('-', "_");

let out_dir = env::var("OUT_DIR").unwrap();

Expand All @@ -91,6 +91,4 @@ pub fn gen_tests_and_benches() {
let g = format!("// {}generated\n\n{}", "@", g);

fs::write(format!("{}/benches_generated.rs", out_dir), g).unwrap();

crate::gen_rustc_nightly();
}
39 changes: 0 additions & 39 deletions api-test/src/gen_rustc_nightly.rs

This file was deleted.

13 changes: 12 additions & 1 deletion api-test/src/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ async fn test_google_impl<C: TlsConnector>() {

t!(tls_stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await);
let mut result = vec![];
t!(tls_stream.read_to_end(&mut result).await);
let res = tls_stream.read_to_end(&mut result).await;

// Google will not send close_notify and just close the connection.
// This means that they are not confirming to TLS exactly, that connections to google.com
// are vulnerable to truncation attacks and that we need to suppress error about this here.
match res {
Ok(_) => {}
Err(e)
if e.to_string()
.contains("peer closed connection without sending TLS close_notify") => {}
Err(e) => panic!("{}", e),
}

println!("{}", String::from_utf8_lossy(&result));
assert!(
Expand Down
9 changes: 4 additions & 5 deletions api-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
//!
//! Probably you don't need this crate outside of `rust-tls-api` repository.

#![cfg_attr(rustc_nightly, feature(test))]
#![feature(test)]

#[macro_use]
extern crate log;

#[cfg(rustc_nightly)]
extern crate test;

use std::any;
Expand All @@ -36,9 +35,6 @@ pub use version::test_version;
mod gen;
pub use gen::gen_tests_and_benches;

mod gen_rustc_nightly;
pub(crate) use gen_rustc_nightly::gen_rustc_nightly;

use tls_api::TlsAcceptor;
use tls_api::TlsAcceptorBox;
use tls_api::TlsAcceptorBuilder;
Expand Down Expand Up @@ -149,6 +145,7 @@ where
))
}

#[allow(dead_code)]
fn new_acceptor_from_der_keys<A: TlsAcceptor>() -> A {
new_acceptor_builder_from_der_keys::<A>().build().unwrap()
}
Expand All @@ -167,6 +164,7 @@ fn new_acceptor_builder_dyn_from_der_keys(acceptor: &dyn TlsAcceptorType) -> Tls
t!(acceptor.builder_from_der_key(keys.cert.get_der(), keys.key.get_der()))
}

#[allow(dead_code)]
fn new_acceptor_dyn_from_der_keys(acceptor: &dyn TlsAcceptorType) -> TlsAcceptorBox {
new_acceptor_builder_dyn_from_der_keys(acceptor)
.build()
Expand Down Expand Up @@ -243,6 +241,7 @@ fn new_connector_builder_dyn_with_root_ca(
connector
}

#[allow(dead_code)]
fn new_connector_dyn_with_root_ca(connector: &dyn TlsConnectorType) -> TlsConnectorBox {
new_connector_builder_dyn_with_root_ca(connector)
.build()
Expand Down
21 changes: 9 additions & 12 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
[package]
name = "tls-api"
version = "0.10.0-pre"
authors = ["Stepan Koltsov <stepan.koltsov@gmail.com>"]
description = "TLS API without implementation"
license = "MIT/Apache-2.0"
repository = "https://github.com/stepancheg/rust-tls-api/"
readme = "../README.md"
keywords = ["tls"]
edition = "2018"
readme = "README.md"
version = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }
keywords = { workspace = true }

[lib]
bench = false

[badges]
travis-ci = { repository = "https://github.com/stepancheg/rust-tls-api/", branch = "master" }

[dependencies]
pem = "0.8.3"
pem = "3.0.4"
tempfile = "3.3.0"
anyhow = "1.0.44"
thiserror = "1.0.30"
thiserror = "2"

# Note technically there's no dependency on async-std
futures-util = { version = "0.3.1", features = ["io"], optional = true }
Expand Down
4 changes: 0 additions & 4 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/stepancheg/rust-tls-api/CI)](https://github.com/stepancheg/rust-tls-api/actions?query=workflow%3ACI)
[![License](https://img.shields.io/crates/l/tls-api.svg)](https://github.com/stepancheg/rust-tls-api/blob/master/LICENSE)
[![crates.io](https://img.shields.io/crates/v/tls-api.svg)](https://crates.io/crates/tls-api)

# tls-api

Implementation neutral common denominator TLS API.
Expand Down
Loading