Maybe the order matters. (#93)

This commit is contained in:
kixelated 2023-10-13 15:59:54 +09:00 committed by GitHub
parent 6c9394db00
commit 5a0357b111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 13 deletions

68
Cargo.lock generated
View File

@ -1156,6 +1156,7 @@ dependencies = [
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
"tracing-subscriber",
"url", "url",
"warp", "warp",
"webtransport-quinn", "webtransport-quinn",
@ -1239,6 +1240,16 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]] [[package]]
name = "num-bigint" name = "num-bigint"
version = "0.4.4" version = "0.4.4"
@ -1351,6 +1362,12 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.1.0" version = "2.1.0"
@ -1900,6 +1917,15 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.1" version = "1.4.1"
@ -2042,6 +2068,16 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if",
"once_cell",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.6.0" version = "1.6.0"
@ -2214,6 +2250,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
] ]
[[package]] [[package]]
@ -2307,6 +2369,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]] [[package]]
name = "value-bag" name = "value-bag"
version = "1.4.1" version = "1.4.1"

View File

@ -45,3 +45,4 @@ clap = { version = "4", features = ["derive"] }
log = { version = "0.4", features = ["std"] } log = { version = "0.4", features = ["std"] }
env_logger = "0.9" env_logger = "0.9"
tracing = "0.1" tracing = "0.1"
tracing-subscriber = "0.3"

View File

@ -22,12 +22,10 @@ async fn main() -> anyhow::Result<()> {
env_logger::init(); env_logger::init();
// Disable tracing so we don't get a bunch of Quinn spam. // Disable tracing so we don't get a bunch of Quinn spam.
/*
let tracer = tracing_subscriber::FmtSubscriber::builder() let tracer = tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::WARN) .with_max_level(tracing::Level::WARN)
.finish(); .finish();
tracing::subscriber::set_global_default(tracer).unwrap(); tracing::subscriber::set_global_default(tracer).unwrap();
*/
let config = Config::parse(); let config = Config::parse();

View File

@ -62,15 +62,17 @@ impl Server {
// Create a list of acceptable root certificates. // Create a list of acceptable root certificates.
let mut client_roots = rustls::RootCertStore::empty(); let mut client_roots = rustls::RootCertStore::empty();
// For local development, we'll accept our own certificate. // Add the platform's native root certificates.
for cert in &certs { for cert in rustls_native_certs::load_native_certs().context("could not load platform certs")? {
client_roots.add(cert).context("failed to add our cert to roots")?; client_roots
.add(&rustls::Certificate(cert.0))
.context("failed to add root cert")?;
} }
// Add the platform's native root certificates. // For local development, we'll accept our own certificate.
for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") { client_roots
client_roots.add(&rustls::Certificate(cert.0)).unwrap(); .add(certs.first().unwrap())
} .context("failed to add our cert to roots")?;
let mut client_config = rustls::ClientConfig::builder() let mut client_config = rustls::ClientConfig::builder()
.with_safe_defaults() .with_safe_defaults()
@ -78,10 +80,7 @@ impl Server {
.with_no_client_auth(); .with_no_client_auth();
let mut server_config = rustls::ServerConfig::builder() let mut server_config = rustls::ServerConfig::builder()
.with_safe_default_cipher_suites() .with_safe_defaults()
.with_safe_default_kx_groups()
.with_protocol_versions(&[&rustls::version::TLS13])
.context("failed to create server config")?
.with_no_client_auth() .with_no_client_auth()
.with_single_cert(certs, key)?; .with_single_cert(certs, key)?;