From 45ee97bd5ad2cc930e5988d365aaec04fe8ee00e Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 18 Jun 2019 21:35:31 +0200 Subject: [PATCH] Upgrade to rcgen 0.4 --- quinn-h3/Cargo.toml | 2 +- quinn-h3/examples/h3.rs | 4 ++-- quinn-proto/Cargo.toml | 2 +- quinn-proto/src/tests/util.rs | 6 +++--- quinn/Cargo.toml | 2 +- quinn/benches/bench.rs | 4 ++-- quinn/examples/common/mod.rs | 4 ++-- quinn/examples/server.rs | 4 ++-- quinn/src/tests.rs | 8 ++++---- quinn/tests/many_connections.rs | 6 ++++-- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/quinn-h3/Cargo.toml b/quinn-h3/Cargo.toml index 85d344dbb..b4e9f86e2 100644 --- a/quinn-h3/Cargo.toml +++ b/quinn-h3/Cargo.toml @@ -42,7 +42,7 @@ directories = "2.0.1" failure = "0.1" proptest = "0.9.1" rand = "0.6.5" -rcgen = "0.3" +rcgen = "0.4" slog-term = "2" structopt = "0.2.7" tokio = "0.1.6" diff --git a/quinn-h3/examples/h3.rs b/quinn-h3/examples/h3.rs index 57f6b72de..477969146 100644 --- a/quinn-h3/examples/h3.rs +++ b/quinn-h3/examples/h3.rs @@ -299,9 +299,9 @@ fn build_certs(log: Logger, options: Opt) -> Result<(CertificateChain, Certifica Ok(x) => x, Err(ref e) if e.kind() == io::ErrorKind::NotFound => { info!(log, "generating self-signed certificate"); - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = cert.serialize_private_key_der(); - let cert = cert.serialize_der(); + let cert = cert.serialize_der().unwrap(); fs::create_dir_all(&path).context("failed to create certificate directory")?; fs::write(&cert_path, &cert).context("failed to write certificate")?; fs::write(&key_path, &key).context("failed to write private key")?; diff --git a/quinn-proto/Cargo.toml b/quinn-proto/Cargo.toml index 1f8c3f3ad..cd07f03f6 100644 --- a/quinn-proto/Cargo.toml +++ b/quinn-proto/Cargo.toml @@ -34,5 +34,5 @@ webpki = "0.19" assert_matches = "1.1" hex-literal = "0.2.0" untrusted = "0.6.2" -rcgen = "0.3" +rcgen = "0.4" #slog = { version = "2.2", features = ["max_level_trace"] } # For debugging diff --git a/quinn-proto/src/tests/util.rs b/quinn-proto/src/tests/util.rs index d88c7c117..bf4098e45 100644 --- a/quinn-proto/src/tests/util.rs +++ b/quinn-proto/src/tests/util.rs @@ -389,7 +389,7 @@ where pub fn server_config() -> ServerConfig { let key = CERTIFICATE.serialize_private_key_der(); - let cert = CERTIFICATE.serialize_pem(); + let cert = CERTIFICATE.serialize_pem().unwrap(); let mut crypto = crypto::rustls::ServerConfig::default(); crypto.set_protocols(&[ALPN_QUIC_HTTP]); @@ -406,7 +406,7 @@ pub fn server_config() -> ServerConfig { } pub fn client_config() -> ClientConfig { - let cert = CERTIFICATE.serialize_der(); + let cert = CERTIFICATE.serialize_der().unwrap(); let anchor = webpki::trust_anchor_util::cert_der_as_trust_anchor(Input::from(&cert)).unwrap(); let anchor_vec = vec![anchor]; @@ -438,5 +438,5 @@ lazy_static! { pub static ref SERVER_PORTS: Mutex> = Mutex::new(4433..); pub static ref CLIENT_PORTS: Mutex> = Mutex::new(44433..); static ref CERTIFICATE: rcgen::Certificate = - rcgen::generate_simple_self_signed(vec!["localhost".into()]); + rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); } diff --git a/quinn/Cargo.toml b/quinn/Cargo.toml index 8d9f583e7..19f8240e8 100644 --- a/quinn/Cargo.toml +++ b/quinn/Cargo.toml @@ -43,7 +43,7 @@ criterion = "0.2.10" directories = "2.0.0" failure = "0.1" rand = "0.6.5" -rcgen = "0.3" +rcgen = "0.4" slog-term = "2" structopt = "0.2.7" tokio = "0.1.6" diff --git a/quinn/benches/bench.rs b/quinn/benches/bench.rs index ce7248cdd..477588d29 100644 --- a/quinn/benches/bench.rs +++ b/quinn/benches/bench.rs @@ -13,9 +13,9 @@ criterion_main!(benches); fn throughput(c: &mut Criterion) { let mut server_config = ServerConfigBuilder::default(); - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = quinn::PrivateKey::from_der(&cert.serialize_private_key_der()).unwrap(); - let cert = quinn::Certificate::from_der(&cert.serialize_der()).unwrap(); + let cert = quinn::Certificate::from_der(&cert.serialize_der().unwrap()).unwrap(); let cert_chain = quinn::CertificateChain::from_certs(vec![cert.clone()]); server_config.certificate(cert_chain, key).unwrap(); diff --git a/quinn/examples/common/mod.rs b/quinn/examples/common/mod.rs index 98c7886da..fdfb39c1f 100644 --- a/quinn/examples/common/mod.rs +++ b/quinn/examples/common/mod.rs @@ -58,8 +58,8 @@ fn configure_client(server_certs: &[&[u8]]) -> Result> /// Returns default server configuration along with its certificate. fn configure_server() -> Result<(ServerConfig, Vec), Box> { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); - let cert_der = cert.serialize_der(); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); + let cert_der = cert.serialize_der().unwrap(); let priv_key = cert.serialize_private_key_der(); let priv_key = PrivateKey::from_der(&priv_key)?; diff --git a/quinn/examples/server.rs b/quinn/examples/server.rs index 86bfe324b..319f3b341 100644 --- a/quinn/examples/server.rs +++ b/quinn/examples/server.rs @@ -124,9 +124,9 @@ fn run(log: Logger, options: Opt) -> Result<()> { Ok(x) => x, Err(ref e) if e.kind() == io::ErrorKind::NotFound => { info!(log, "generating self-signed certificate"); - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = cert.serialize_private_key_der(); - let cert = cert.serialize_der(); + let cert = cert.serialize_der().unwrap(); fs::create_dir_all(&path).context("failed to create certificate directory")?; fs::write(&cert_path, &cert).context("failed to write certificate")?; fs::write(&key_path, &key).context("failed to write private key")?; diff --git a/quinn/src/tests.rs b/quinn/src/tests.rs index 3f246fc1e..de83af1ee 100644 --- a/quinn/src/tests.rs +++ b/quinn/src/tests.rs @@ -145,9 +145,9 @@ fn read_after_close() { let mut endpoint = Endpoint::builder(); let mut server_config = ServerConfigBuilder::default(); - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = crate::PrivateKey::from_der(&cert.serialize_private_key_der()).unwrap(); - let cert = crate::Certificate::from_der(&cert.serialize_der()).unwrap(); + let cert = crate::Certificate::from_der(&cert.serialize_der().unwrap()).unwrap(); let cert_chain = crate::CertificateChain::from_certs(vec![cert.clone()]); server_config.certificate(cert_chain, key).unwrap(); endpoint.listen(server_config.build()); @@ -241,9 +241,9 @@ fn run_echo(client_addr: SocketAddr, server_addr: SocketAddr) { { let log = logger(); let mut server_config = ServerConfigBuilder::default(); - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]); + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = crate::PrivateKey::from_der(&cert.serialize_private_key_der()).unwrap(); - let cert = crate::Certificate::from_der(&cert.serialize_der()).unwrap(); + let cert = crate::Certificate::from_der(&cert.serialize_der().unwrap()).unwrap(); let cert_chain = crate::CertificateChain::from_certs(vec![cert.clone()]); server_config.certificate(cert_chain, key).unwrap(); diff --git a/quinn/tests/many_connections.rs b/quinn/tests/many_connections.rs index bf14dcce0..5ee01792a 100644 --- a/quinn/tests/many_connections.rs +++ b/quinn/tests/many_connections.rs @@ -174,11 +174,13 @@ fn configure_listener() -> (quinn::ServerConfig, Vec) { } fn gen_cert() -> (Vec, quinn::PrivateKey) { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_string()]); + let cert = unwrap!(rcgen::generate_simple_self_signed(vec![ + "localhost".to_string() + ])); let key = unwrap!(quinn::PrivateKey::from_der( &cert.serialize_private_key_der() )); - (cert.serialize_der(), key) + (unwrap!(cert.serialize_der()), key) } /// Constructs a buffer with random bytes of given size prefixed with a hash of this data.