Skip to content

Commit 38bfe5e

Browse files
chore(deps): upgrade rcgen to 0.13 (#2934)
## Description Some breaking changes in rcgen, but all pretty straightforward. - [x] `iroh-net` - [x] `iroh-relay` - [x] `iroh-net-bench` - [x] `iroh-dns-server` `rcgen` changelog: https://github.com/rustls/rcgen/blob/main/rcgen/CHANGELOG.md#release-0130---march-28th-2024 The last remaining `0.12` usage, will be gone after this is released: n0-computer/tokio-rustls-acme#17 ## Breaking Changes None ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented.
1 parent 09c54e4 commit 38bfe5e

File tree

9 files changed

+156
-51
lines changed

9 files changed

+156
-51
lines changed

Cargo.lock

Lines changed: 18 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-dns-server/Cargo.toml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ axum-server = { version = "0.7", features = ["tls-rustls-no-provider"] }
1717
base64-url = "2.0.2"
1818
bytes = "1.7"
1919
clap = { version = "4.5.1", features = ["derive"] }
20-
derive_more = { version = "1.0.0", features = ["debug", "display", "into", "from"] }
20+
derive_more = { version = "1.0.0", features = [
21+
"debug",
22+
"display",
23+
"into",
24+
"from",
25+
] }
2126
dirs-next = "2.0.0"
2227
futures-lite = "2.3.0"
2328
governor = "0.6.3"
@@ -28,8 +33,12 @@ iroh-metrics = { version = "0.28.0" }
2833
lru = "0.12.3"
2934
mainline = "2.0.1"
3035
parking_lot = "0.12.1"
31-
pkarr = { version = "2.2.0", features = [ "async", "relay", "dht"], default-features = false }
32-
rcgen = "0.12.1"
36+
pkarr = { version = "2.2.0", features = [
37+
"async",
38+
"relay",
39+
"dht",
40+
], default-features = false }
41+
rcgen = "0.13"
3342
redb = "2.0.0"
3443
regex = "1.10.3"
3544
rustls = { version = "0.23", default-features = false, features = ["ring"] }
@@ -38,7 +47,10 @@ serde = { version = "1.0.197", features = ["derive"] }
3847
struct_iterable = "0.1.1"
3948
strum = { version = "0.26.1", features = ["derive"] }
4049
tokio = { version = "1.36.0", features = ["full"] }
41-
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "ring"] }
50+
tokio-rustls = { version = "0.26", default-features = false, features = [
51+
"logging",
52+
"ring",
53+
] }
4254
tokio-rustls-acme = { version = "0.4", features = ["axum"] }
4355
tokio-stream = "0.1.14"
4456
tokio-util = "0.7.10"

iroh-dns-server/src/http/tls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ impl<I: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: Send + 'static> Acce
7474

7575
impl TlsAcceptor {
7676
async fn self_signed(domains: Vec<String>) -> Result<Self> {
77-
let tls_cert = rcgen::generate_simple_self_signed(domains)?;
78-
let key = tls_cert.serialize_private_key_der();
79-
let config = RustlsConfig::from_der(vec![tls_cert.serialize_der()?], key).await?;
77+
let rcgen::CertifiedKey { cert, key_pair } = rcgen::generate_simple_self_signed(domains)?;
78+
let config =
79+
RustlsConfig::from_der(vec![cert.der().to_vec()], key_pair.serialize_der()).await?;
8080
let acceptor = RustlsAcceptor::new(config);
8181
Ok(Self::Manual(acceptor))
8282
}

iroh-net/Cargo.toml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ base64 = "0.22.1"
2525
bytes = "1.7"
2626
clap = { version = "4", features = ["derive"], optional = true }
2727
der = { version = "0.7", features = ["alloc", "derive"] }
28-
derive_more = { version = "1.0.0", features = ["debug", "display", "from", "try_into", "deref"] }
28+
derive_more = { version = "1.0.0", features = [
29+
"debug",
30+
"display",
31+
"from",
32+
"try_into",
33+
"deref",
34+
] }
2935
futures-buffered = "0.2.8"
3036
futures-concurrency = "7.6.0"
3137
futures-lite = "2.3"
@@ -50,16 +56,25 @@ num_enum = "0.7"
5056
once_cell = "1.18.0"
5157
parking_lot = "0.12.1"
5258
pin-project = "1"
53-
pkarr = { version = "2", default-features = false, features = ["async", "relay"] }
59+
pkarr = { version = "2", default-features = false, features = [
60+
"async",
61+
"relay",
62+
] }
5463
portmapper = { version = "0.1.0", path = "../net-tools/portmapper" }
55-
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
64+
postcard = { version = "1", default-features = false, features = [
65+
"alloc",
66+
"use-std",
67+
"experimental-derive",
68+
] }
5669
quinn = { package = "iroh-quinn", version = "0.12.0" }
5770
quinn-proto = { package = "iroh-quinn-proto", version = "0.12.0" }
5871
quinn-udp = { package = "iroh-quinn-udp", version = "0.5.5" }
5972
rand = "0.8"
60-
rcgen = "0.12"
73+
rcgen = "0.13"
6174
regex = { version = "1.7.1", optional = true }
62-
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
75+
reqwest = { version = "0.12", default-features = false, features = [
76+
"rustls-tls",
77+
] }
6378
ring = "0.17"
6479
rustls = { version = "0.23", default-features = false, features = ["ring"] }
6580
serde = { version = "1", features = ["derive", "rc"] }
@@ -69,14 +84,29 @@ stun-rs = "0.1.5"
6984
surge-ping = "0.8.0"
7085
thiserror = "1"
7186
time = "0.3.20"
72-
tokio = { version = "1", features = ["io-util", "macros", "sync", "rt", "net", "fs", "io-std", "signal", "process"] }
73-
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "ring"] }
87+
tokio = { version = "1", features = [
88+
"io-util",
89+
"macros",
90+
"sync",
91+
"rt",
92+
"net",
93+
"fs",
94+
"io-std",
95+
"signal",
96+
"process",
97+
] }
98+
tokio-rustls = { version = "0.26", default-features = false, features = [
99+
"logging",
100+
"ring",
101+
] }
74102
tokio-stream = { version = "0.1.15" }
75103
tokio-tungstenite = "0.21"
76104
tokio-tungstenite-wasm = "0.3"
77105
tokio-util = { version = "0.7.12", features = ["io-util", "io", "codec", "rt"] }
78106
tracing = "0.1"
79-
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
107+
tracing-subscriber = { version = "0.3", features = [
108+
"env-filter",
109+
], optional = true }
80110
tungstenite = "0.21"
81111
url = { version = "2.4", features = ["serde"] }
82112
watchable = "1.1.2"
@@ -103,7 +133,12 @@ rtnetlink = "0.13.0"
103133

104134
[target.'cfg(target_os = "windows")'.dependencies]
105135
wmi = "0.13"
106-
windows = { version = "0.51", features = ["Win32_NetworkManagement_IpHelper", "Win32_Foundation", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"] }
136+
windows = { version = "0.51", features = [
137+
"Win32_NetworkManagement_IpHelper",
138+
"Win32_Foundation",
139+
"Win32_NetworkManagement_Ndis",
140+
"Win32_Networking_WinSock",
141+
] }
107142

108143
[dev-dependencies]
109144
axum = { version = "0.7.4" }
@@ -112,7 +147,16 @@ criterion = "0.5.1"
112147
crypto_box = { version = "0.9.1", features = ["serde", "chacha20"] }
113148
pretty_assertions = "1.4"
114149
rand_chacha = "0.3.1"
115-
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
150+
tokio = { version = "1", features = [
151+
"io-util",
152+
"sync",
153+
"rt",
154+
"net",
155+
"fs",
156+
"macros",
157+
"time",
158+
"test-util",
159+
] }
116160
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
117161
iroh-test = "0.28.0"
118162
iroh-net = { path = "." }

iroh-net/bench/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ hdrhistogram = { version = "7.2", default-features = false }
1212
iroh-net = { path = ".." }
1313
iroh-metrics = { path = "../../iroh-metrics" }
1414
quinn = { package = "iroh-quinn", version = "0.12" }
15-
rcgen = "0.12"
15+
rcgen = "0.13"
1616
rustls = { version = "0.23", default-features = false, features = ["ring"] }
1717
clap = { version = "4", features = ["derive"] }
1818
tokio = { version = "1.0.1", features = ["rt", "sync"] }
1919
tracing = "0.1"
20-
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time"] }
20+
tracing-subscriber = { version = "0.3.0", default-features = false, features = [
21+
"env-filter",
22+
"fmt",
23+
"ansi",
24+
"time",
25+
"local-time",
26+
] }
2127
socket2 = "0.5"
2228
futures-lite = "2.3.0"
2329

iroh-net/src/test_utils.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ pub async fn run_relay_server_with(
4242
let cert =
4343
rcgen::generate_simple_self_signed(vec!["localhost".to_string(), "127.0.0.1".to_string()])
4444
.expect("valid");
45-
let rustls_cert = rustls::pki_types::CertificateDer::from(cert.serialize_der().unwrap());
46-
let private_key =
47-
rustls::pki_types::PrivatePkcs8KeyDer::from(cert.get_key_pair().serialize_der());
45+
let rustls_cert = cert.cert.der();
46+
let private_key = rustls::pki_types::PrivatePkcs8KeyDer::from(cert.key_pair.serialize_der());
4847
let private_key = rustls::pki_types::PrivateKeyDer::from(private_key);
4948

5049
let config = ServerConfig {
@@ -53,7 +52,7 @@ pub async fn run_relay_server_with(
5352
tls: Some(TlsConfig {
5453
cert: CertConfig::<(), ()>::Manual {
5554
private_key,
56-
certs: vec![rustls_cert],
55+
certs: vec![rustls_cert.clone()],
5756
},
5857
https_bind_addr: (Ipv4Addr::LOCALHOST, 0).into(),
5958
}),

iroh-net/src/tls/certificate.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,22 @@ pub fn generate(
9191
// Endpoints MAY generate a new key and certificate
9292
// for every connection attempt, or they MAY reuse the same key
9393
// and certificate for multiple connections.
94-
let certificate_keypair = rcgen::KeyPair::generate(P2P_SIGNATURE_ALGORITHM)?;
94+
let certificate_keypair = rcgen::KeyPair::generate_for(P2P_SIGNATURE_ALGORITHM)?;
9595
let rustls_key =
9696
rustls::pki_types::PrivateKeyDer::try_from(certificate_keypair.serialize_der()).unwrap();
9797
let certificate = {
98-
let mut params = rcgen::CertificateParams::new(vec![]);
98+
let mut params = rcgen::CertificateParams::default();
9999
params.distinguished_name = rcgen::DistinguishedName::new();
100100
params.custom_extensions.push(make_libp2p_extension(
101101
identity_secret_key,
102102
&certificate_keypair,
103103
)?);
104-
params.alg = P2P_SIGNATURE_ALGORITHM;
105-
params.key_pair = Some(certificate_keypair);
106-
rcgen::Certificate::from_params(params)?
104+
params
105+
.self_signed(&certificate_keypair)
106+
.expect("self signed certificate to be generated")
107107
};
108108

109-
let rustls_certificate = rustls::pki_types::CertificateDer::from(certificate.serialize_der()?);
110-
111-
Ok((rustls_certificate, rustls_key))
109+
Ok((certificate.der().clone(), rustls_key))
112110
}
113111

114112
/// Attempts to parse the provided bytes as a [`P2pCertificate`].

iroh-relay/Cargo.toml

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ anyhow = { version = "1" }
1818
base64 = "0.22.1"
1919
bytes = "1.7"
2020
clap = { version = "4", features = ["derive"], optional = true }
21-
derive_more = { version = "1.0.0", features = ["debug", "display", "from", "try_into", "deref"] }
21+
derive_more = { version = "1.0.0", features = [
22+
"debug",
23+
"display",
24+
"from",
25+
"try_into",
26+
"deref",
27+
] }
2228
futures-buffered = "0.2.9"
2329
futures-lite = "2.3"
2430
futures-sink = "0.3.25"
@@ -33,17 +39,23 @@ http-body-util = "0.1.0"
3339
hyper = { version = "1", features = ["server", "client", "http1"] }
3440
hyper-util = "0.1.1"
3541
iroh-base = { version = "0.28.0", features = ["key"] }
36-
iroh-metrics = { version = "0.28.0", default-features = false}
42+
iroh-metrics = { version = "0.28.0", default-features = false }
3743
libc = "0.2.139"
3844
num_enum = "0.7"
3945
once_cell = "1.18.0"
4046
parking_lot = "0.12.1"
4147
pin-project = "1"
42-
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
48+
postcard = { version = "1", default-features = false, features = [
49+
"alloc",
50+
"use-std",
51+
"experimental-derive",
52+
] }
4353
rand = "0.8"
44-
rcgen = { version = "0.12", optional = true}
54+
rcgen = { version = "0.13", optional = true }
4555
regex = { version = "1.7.1", optional = true }
46-
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
56+
reqwest = { version = "0.12", default-features = false, features = [
57+
"rustls-tls",
58+
] }
4759
ring = "0.17"
4860
rustls = { version = "0.23", default-features = false, features = ["ring"] }
4961
rustls-pemfile = { version = "2.1", optional = true }
@@ -53,15 +65,30 @@ socket2 = "0.5.3"
5365
stun-rs = "0.1.5"
5466
thiserror = "1"
5567
time = "0.3.20"
56-
tokio = { version = "1", features = ["io-util", "macros", "sync", "rt", "net", "fs", "io-std", "signal", "process"] }
57-
tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "ring"] }
68+
tokio = { version = "1", features = [
69+
"io-util",
70+
"macros",
71+
"sync",
72+
"rt",
73+
"net",
74+
"fs",
75+
"io-std",
76+
"signal",
77+
"process",
78+
] }
79+
tokio-rustls = { version = "0.26", default-features = false, features = [
80+
"logging",
81+
"ring",
82+
] }
5883
tokio-rustls-acme = { version = "0.4", optional = true }
5984
tokio-tungstenite = "0.21"
6085
tokio-tungstenite-wasm = "0.3"
6186
tokio-util = { version = "0.7.12", features = ["io-util", "io", "codec", "rt"] }
6287
toml = { version = "0.8", optional = true }
6388
tracing = "0.1"
64-
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
89+
tracing-subscriber = { version = "0.3", features = [
90+
"env-filter",
91+
], optional = true }
6592
tungstenite = "0.21"
6693
url = { version = "2.4", features = ["serde"] }
6794
webpki = { package = "rustls-webpki", version = "0.102" }
@@ -72,7 +99,16 @@ clap = { version = "4", features = ["derive"] }
7299
crypto_box = { version = "0.9.1", features = ["serde", "chacha20"] }
73100
proptest = "1.2.0"
74101
rand_chacha = "0.3.1"
75-
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
102+
tokio = { version = "1", features = [
103+
"io-util",
104+
"sync",
105+
"rt",
106+
"net",
107+
"fs",
108+
"macros",
109+
"time",
110+
"test-util",
111+
] }
76112
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
77113
iroh-test = "0.28.0"
78114
serde_json = "1.0.107"

0 commit comments

Comments
 (0)