From 27287e13fa125234898d9aabd7d9d640aba92a36 Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Fri, 15 Nov 2024 17:19:19 +0200 Subject: [PATCH] chore: update rcgen inspired by https://github.com/n0-computer/iroh/pull/2934 --- Cargo.lock | 19 ++++++++++++++++--- Cargo.toml | 2 +- examples/split/server/Cargo.toml | 2 +- examples/split/server/src/main.rs | 9 ++++----- tests/quinn.rs | 9 ++++----- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fca828..83ece12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1841,7 +1841,7 @@ dependencies = [ "portmapper", "postcard", "rand", - "rcgen", + "rcgen 0.12.1", "reqwest", "ring", "rtnetlink", @@ -2951,7 +2951,7 @@ dependencies = [ "nested_enum_utils", "pin-project", "proc-macro2", - "rcgen", + "rcgen 0.13.1", "serde", "slab", "tempfile", @@ -3102,6 +3102,19 @@ dependencies = [ "yasna", ] +[[package]] +name = "rcgen" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" +dependencies = [ + "pem", + "ring", + "rustls-pki-types", + "time", + "yasna", +] + [[package]] name = "redox_syscall" version = "0.5.7" @@ -3593,7 +3606,7 @@ dependencies = [ "futures", "iroh-quinn", "quic-rpc", - "rcgen", + "rcgen 0.13.1", "rustls", "serde", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 2c12150..13650f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ async-stream = "0.3.3" serde = { version = "1", features = ["derive"] } tokio = { version = "1", features = ["full"] } quinn = { package = "iroh-quinn", version = "0.12", features = ["ring"] } -rcgen = "0.12" +rcgen = "0.13" thousands = "0.2.0" tracing-subscriber = "0.3.16" tempfile = "3.5.0" diff --git a/examples/split/server/Cargo.toml b/examples/split/server/Cargo.toml index 646eb32..f5db77d 100644 --- a/examples/split/server/Cargo.toml +++ b/examples/split/server/Cargo.toml @@ -12,7 +12,7 @@ futures = "0.3.26" tracing-subscriber = "0.3.16" quic-rpc = { path = "../../..", features = ["quinn-transport", "macros"] } quinn = { package = "iroh-quinn", version = "0.12" } -rcgen = "0.12.0" +rcgen = "0.13" rustls = { version = "0.23", default-features = false, features = ["ring"] } serde = { version = "1", features = ["derive"] } tokio = { version = "1", features = ["full"] } diff --git a/examples/split/server/src/main.rs b/examples/split/server/src/main.rs index 1f1dd8a..045a9d2 100644 --- a/examples/split/server/src/main.rs +++ b/examples/split/server/src/main.rs @@ -80,15 +80,14 @@ fn make_server_endpoint(bind_addr: SocketAddr) -> anyhow::Result<(Endpoint, Vec< fn configure_server() -> anyhow::Result<(ServerConfig, Vec)> { let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()])?; - let cert_der = cert.serialize_der()?; - let priv_key = cert.serialize_private_key_der(); - let priv_key = rustls::pki_types::PrivatePkcs8KeyDer::from(priv_key); - let cert_chain = vec![rustls::pki_types::CertificateDer::from(cert_der.clone())]; + let cert_der = cert.cert.der(); + let priv_key = rustls::pki_types::PrivatePkcs8KeyDer::from(cert.key_pair.serialize_der()); + let cert_chain = vec![cert_der.clone()]; let mut server_config = ServerConfig::with_single_cert(cert_chain, priv_key.into())?; Arc::get_mut(&mut server_config.transport) .unwrap() .max_concurrent_uni_streams(0_u8.into()); - Ok((server_config, cert_der)) + Ok((server_config, cert_der.to_vec())) } diff --git a/tests/quinn.rs b/tests/quinn.rs index 40c3e55..a152309 100644 --- a/tests/quinn.rs +++ b/tests/quinn.rs @@ -80,10 +80,9 @@ fn configure_client(server_certs: &[&[u8]]) -> anyhow::Result { #[allow(clippy::field_reassign_with_default)] // https://github.com/rust-lang/rust-clippy/issues/6527 fn configure_server() -> anyhow::Result<(ServerConfig, Vec)> { let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()])?; - let cert_der = cert.serialize_der()?; - let priv_key = cert.serialize_private_key_der(); - let priv_key = rustls::pki_types::PrivatePkcs8KeyDer::from(priv_key); - let cert_chain = vec![rustls::pki_types::CertificateDer::from(cert_der.clone())]; + let cert_der = cert.cert.der(); + let priv_key = rustls::pki_types::PrivatePkcs8KeyDer::from(cert.key_pair.serialize_der()); + let cert_chain = vec![cert_der.clone()]; let crypto_server_config = rustls::ServerConfig::builder_with_provider(Arc::new( rustls::crypto::ring::default_provider(), @@ -99,7 +98,7 @@ fn configure_server() -> anyhow::Result<(ServerConfig, Vec)> { .unwrap() .max_concurrent_uni_streams(0_u8.into()); - Ok((server_config, cert_der)) + Ok((server_config, cert_der.to_vec())) } pub struct Endpoints {