From da10ad28dcacad83b9b0c86d89c15468d7db567a Mon Sep 17 00:00:00 2001 From: _ <> Date: Fri, 1 Oct 2021 12:44:20 -0500 Subject: [PATCH] add `--cert-url` to end server too --- Cargo.lock | 1 + prototypes/quic_demo/Cargo.toml | 1 + prototypes/quic_demo/src/bin/quic_demo_end_server.rs | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2a4a2f6..ae75527 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1332,6 +1332,7 @@ dependencies = [ "hyper", "quinn", "rcgen", + "reqwest", "rmp-serde", "structopt", "tokio", diff --git a/prototypes/quic_demo/Cargo.toml b/prototypes/quic_demo/Cargo.toml index a2e7d78..d10125b 100644 --- a/prototypes/quic_demo/Cargo.toml +++ b/prototypes/quic_demo/Cargo.toml @@ -15,6 +15,7 @@ futures-util = "0.3.9" hyper = { version = "0.14.4", features = ["http1", "server", "stream", "tcp"] } quinn = "0.7.2" rcgen = "0.8.11" +reqwest = "0.11.4" rmp-serde = "0.15.5" structopt = "0.3.20" tokio = { version = "1.8.1", features = ["full"] } diff --git a/prototypes/quic_demo/src/bin/quic_demo_end_server.rs b/prototypes/quic_demo/src/bin/quic_demo_end_server.rs index 26c6c6d..5f28433 100644 --- a/prototypes/quic_demo/src/bin/quic_demo_end_server.rs +++ b/prototypes/quic_demo/src/bin/quic_demo_end_server.rs @@ -12,6 +12,8 @@ struct Opt { server_id: Option , #[structopt (long)] debug_echo: bool, + #[structopt (long)] + cert_url: Option , } #[tokio::main] @@ -20,7 +22,10 @@ async fn main () -> anyhow::Result <()> { let opt = Arc::new (Opt::from_args ()); - let server_cert = tokio::fs::read ("quic_server.crt").await?; + let server_cert = match opt.cert_url.as_ref () { + Some (url) => reqwest::get (url).await?.bytes ().await?, + None => tokio::fs::read ("quic_server.crt").await?.into (), + }; let relay_addr = opt.relay_addr.clone ().unwrap_or_else (|| String::from ("127.0.0.1:30380")).parse ()?; let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;