From 802d12806a00a7a4be9779a9bb7e4722fbe8bd11 Mon Sep 17 00:00:00 2001 From: haurog <36535774+haurog@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:43:14 +0200 Subject: [PATCH 1/3] Use newer version for rcgen enable RISC-V builds. --- Cargo.lock | 22 +++++++++++++++++----- Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fda6b57aa8..b90959e39a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3383,7 +3383,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "libp2p-yamux", - "rcgen", + "rcgen 0.12.1", "ring 0.17.8", "rustls 0.23.11", "rustls-webpki 0.101.7", @@ -3436,7 +3436,7 @@ dependencies = [ "multihash", "quickcheck", "rand 0.8.5", - "rcgen", + "rcgen 0.12.1", "serde", "stun 0.6.0", "thiserror", @@ -3504,7 +3504,7 @@ dependencies = [ "libp2p-tcp", "parking_lot", "pin-project-lite", - "rcgen", + "rcgen 0.12.1", "rw-stream-sink", "soketto", "thiserror", @@ -4756,6 +4756,18 @@ dependencies = [ "yasna", ] +[[package]] +name = "rcgen" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48406db8ac1f3cbc7dcdb56ec355343817958a356ff430259bb07baf7607e1e1" +dependencies = [ + "pem", + "ring 0.17.8", + "time", + "yasna", +] + [[package]] name = "redis" version = "0.24.0" @@ -6673,7 +6685,7 @@ dependencies = [ "log", "pem", "rand 0.8.5", - "rcgen", + "rcgen 0.11.3", "regex", "ring 0.16.20", "rtcp", @@ -6737,7 +6749,7 @@ dependencies = [ "pem", "rand 0.8.5", "rand_core 0.6.4", - "rcgen", + "rcgen 0.11.3", "ring 0.16.20", "rustls 0.21.11", "sec1", diff --git a/Cargo.toml b/Cargo.toml index 55fc43d5b5a..b6fab33df3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,7 +130,7 @@ tracing-subscriber = "0.3" futures = "0.3.30" web-time = "1.1.0" ring = "0.17.8" -rcgen = "0.11.3" +rcgen = "0.12.1" [patch.crates-io] From 0cf1ccb7b84194e8f19ddae23950ae21230a8a55 Mon Sep 17 00:00:00 2001 From: haurog <36535774+haurog@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:43:57 +0200 Subject: [PATCH 2/3] Fix deprecation warnings for errors due to move to newer rcgen --- transports/tls/src/certificate.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transports/tls/src/certificate.rs b/transports/tls/src/certificate.rs index 65b373bcf9b..c0e1a043b27 100644 --- a/transports/tls/src/certificate.rs +++ b/transports/tls/src/certificate.rs @@ -158,7 +158,7 @@ pub struct P2pExtension { #[derive(Debug, thiserror::Error)] #[error(transparent)] -pub struct GenError(#[from] rcgen::RcgenError); +pub struct GenError(#[from] rcgen::Error); #[derive(Debug, thiserror::Error)] #[error(transparent)] @@ -244,7 +244,7 @@ fn parse_unverified(der_input: &[u8]) -> Result { fn make_libp2p_extension( identity_keypair: &identity::Keypair, certificate_keypair: &rcgen::KeyPair, -) -> Result { +) -> Result { // The peer signs the concatenation of the string `libp2p-tls-handshake:` // and the public key that it used to generate the certificate carrying // the libp2p Public Key Extension, using its private host key. @@ -255,7 +255,7 @@ fn make_libp2p_extension( identity_keypair .sign(&msg) - .map_err(|_| rcgen::RcgenError::RingUnspecified)? + .map_err(|_| rcgen::Error::RingUnspecified)? }; // The public host key and the signature are ANS.1-encoded From 9cc9699b830c1bd4e5dad54f9326d5fae43e884c Mon Sep 17 00:00:00 2001 From: haurog <36535774+haurog@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:06:57 +0200 Subject: [PATCH 3/3] upgrade rcgen to v0.13.1 --- Cargo.lock | 286 ++++++--------------- Cargo.toml | 2 +- transports/tls/src/certificate.rs | 11 +- transports/webrtc/Cargo.toml | 2 +- transports/webrtc/src/tokio/certificate.rs | 10 +- 5 files changed, 94 insertions(+), 217 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4e4f074ce1..604dfe92571 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,7 +176,6 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time", ] [[package]] @@ -1322,7 +1321,6 @@ dependencies = [ "asn1-rs 0.5.2", "displaydoc", "nom", - "num-bigint", "num-traits", "rusticata-macros", ] @@ -2435,13 +2433,14 @@ checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" [[package]] name = "interceptor" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5927883184e6a819b22d5e4f5f7bc7ca134fde9b2026fbddd8d95249746ba21e" +checksum = "4705c00485029e738bea8c9505b5ddb1486a8f3627a953e1e77e6abdf5eef90c" dependencies = [ "async-trait", "bytes", "log", + "portable-atomic", "rand 0.8.5", "rtcp", "rtp", @@ -2449,7 +2448,7 @@ dependencies = [ "tokio", "waitgroup", "webrtc-srtp", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] @@ -2914,7 +2913,7 @@ dependencies = [ "quick-protobuf", "quickcheck-ext", "rand 0.8.5", - "ring 0.17.8", + "ring", "rmp-serde", "sec1", "serde", @@ -3195,7 +3194,7 @@ dependencies = [ "quickcheck", "quinn", "rand 0.8.5", - "ring 0.17.8", + "ring", "rustls 0.23.11", "socket2 0.5.7", "thiserror", @@ -3420,13 +3419,13 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "libp2p-yamux", - "rcgen 0.12.1", - "ring 0.17.8", + "rcgen", + "ring", "rustls 0.23.11", "rustls-webpki 0.101.7", "thiserror", "tokio", - "x509-parser 0.16.0", + "x509-parser", "yasna", ] @@ -3473,9 +3472,9 @@ dependencies = [ "multihash", "quickcheck", "rand 0.8.5", - "rcgen 0.12.1", + "rcgen", "serde", - "stun 0.6.0", + "stun", "thiserror", "tinytemplate", "tokio", @@ -3541,7 +3540,7 @@ dependencies = [ "libp2p-tcp", "parking_lot", "pin-project-lite", - "rcgen 0.12.1", + "rcgen", "rw-stream-sink", "soketto", "thiserror", @@ -4101,15 +4100,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - [[package]] name = "oid-registry" version = "0.7.0" @@ -4740,7 +4730,7 @@ checksum = "e974563a4b1c2206bbc61191ca4da9c22e4308b4c455e8906751cc7828393f08" dependencies = [ "bytes", "rand 0.8.5", - "ring 0.17.8", + "ring", "rustc-hash", "rustls 0.23.11", "slab", @@ -4864,26 +4854,15 @@ dependencies = [ [[package]] name = "rcgen" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6" -dependencies = [ - "pem", - "ring 0.16.20", - "time", - "x509-parser 0.15.1", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.12.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48406db8ac1f3cbc7dcdb56ec355343817958a356ff430259bb07baf7607e1e1" +checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" dependencies = [ "pem", - "ring 0.17.8", + "ring", + "rustls-pki-types", "time", + "x509-parser", "yasna", ] @@ -5070,21 +5049,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -5095,8 +5059,8 @@ dependencies = [ "cfg-if", "getrandom 0.2.15", "libc", - "spin 0.9.8", - "untrusted 0.9.0", + "spin", + "untrusted", "windows-sys 0.52.0", ] @@ -5133,13 +5097,13 @@ dependencies = [ [[package]] name = "rtcp" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3677908cadfbecb4cc1da9a56a32524fae4ebdfa7c2ea93886e1b1e846488cb9" +checksum = "fc9f775ff89c5fe7f0cc0abafb7c57688ae25ce688f1a52dd88e277616c76ab2" dependencies = [ "bytes", "thiserror", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] @@ -5160,15 +5124,16 @@ dependencies = [ [[package]] name = "rtp" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e60482acbe8afb31edf6b1413103b7bca7a65004c423b3c3993749a083994fbe" +checksum = "6870f09b5db96f8b9e7290324673259fd15519ebb7d55acf8e7eb044a9ead6af" dependencies = [ "bytes", + "portable-atomic", "rand 0.8.5", "serde", "thiserror", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] @@ -5264,18 +5229,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.21.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" -dependencies = [ - "log", - "ring 0.17.8", - "rustls-webpki 0.101.7", - "sct", -] - [[package]] name = "rustls" version = "0.22.4" @@ -5283,7 +5236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.8", + "ring", "rustls-pki-types", "rustls-webpki 0.102.5", "subtle", @@ -5297,7 +5250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", - "ring 0.17.8", + "ring", "rustls-pki-types", "rustls-webpki 0.102.5", "subtle", @@ -5326,8 +5279,8 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -5336,9 +5289,9 @@ version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ - "ring 0.17.8", + "ring", "rustls-pki-types", - "untrusted 0.9.0", + "untrusted", ] [[package]] @@ -5402,21 +5355,11 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "sdp" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4653054c30ebce63658762eb0d64e27673868a95564474811ae6c220cf767640" +checksum = "13254db766b17451aced321e7397ebf0a446ef0c8d2942b6e67a95815421093f" dependencies = [ "rand 0.8.5", "substring", @@ -5700,7 +5643,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek", "rand_core 0.6.4", - "ring 0.17.8", + "ring", "rustc_version", "sha2 0.10.8", "subtle", @@ -5741,12 +5684,6 @@ dependencies = [ "sha1", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -5820,25 +5757,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "stun" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f371788132e9d623e6eab4ba28aac083763a4133f045e6ebaee5ceb869803d" -dependencies = [ - "base64 0.21.7", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring 0.17.8", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util 0.8.1", -] - [[package]] name = "stun" version = "0.6.0" @@ -5850,12 +5768,12 @@ dependencies = [ "lazy_static", "md-5", "rand 0.8.5", - "ring 0.17.8", + "ring", "subtle", "thiserror", "tokio", "url", - "webrtc-util 0.9.0", + "webrtc-util", ] [[package]] @@ -6468,21 +6386,23 @@ dependencies = [ [[package]] name = "turn" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f4fcb97da0426e8146fe0e9b78cc13120161087256198701d12d9df77f7701" +checksum = "8b000cebd930420ac1ed842c8128e3b3412512dfd5b82657eab035a3f5126acc" dependencies = [ "async-trait", "base64 0.21.7", "futures", "log", "md-5", + "portable-atomic", "rand 0.8.5", - "ring 0.16.20", - "stun 0.5.1", + "ring", + "stun", "thiserror", "tokio", - "webrtc-util 0.8.1", + "tokio-util", + "webrtc-util", ] [[package]] @@ -6565,12 +6485,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -6846,9 +6760,9 @@ dependencies = [ [[package]] name = "webrtc" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91e7cf018f7185552bf6a5dd839f4ed9827aea33b746763c9a215f84a0d0b34" +checksum = "d8b3a840e31c969844714f93b5a87e73ee49f3bc2a4094ab9132c69497eb31db" dependencies = [ "arc-swap", "async-trait", @@ -6859,19 +6773,20 @@ dependencies = [ "lazy_static", "log", "pem", + "portable-atomic", "rand 0.8.5", - "rcgen 0.11.3", + "rcgen", "regex", - "ring 0.16.20", + "ring", "rtcp", "rtp", - "rustls 0.21.11", + "rustls 0.23.11", "sdp", "serde", "serde_json", "sha2 0.10.8", "smol_str", - "stun 0.5.1", + "stun", "thiserror", "time", "tokio", @@ -6885,28 +6800,29 @@ dependencies = [ "webrtc-media", "webrtc-sctp", "webrtc-srtp", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] name = "webrtc-data" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45d2461d0e0bf93f181e30eb0b40df32b8bf3efb89c53cebb1990e603e2067d" +checksum = "f8b7c550f8d35867b72d511640adf5159729b9692899826fe00ba7fa74f0bf70" dependencies = [ "bytes", "log", + "portable-atomic", "thiserror", "tokio", "webrtc-sctp", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] name = "webrtc-dtls" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b140b953f986e97828aa33ec6318186b05d862bee689efbc57af04a243e832" +checksum = "86e5eedbb0375aa04da93fc3a189b49ed3ed9ee844b6997d5aade14fc3e2c26e" dependencies = [ "aes", "aes-gcm", @@ -6922,11 +6838,12 @@ dependencies = [ "p256", "p384", "pem", + "portable-atomic", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.11.3", - "ring 0.16.20", - "rustls 0.21.11", + "rcgen", + "ring", + "rustls 0.23.11", "sec1", "serde", "sha1", @@ -6934,25 +6851,26 @@ dependencies = [ "subtle", "thiserror", "tokio", - "webrtc-util 0.8.1", + "webrtc-util", "x25519-dalek", - "x509-parser 0.15.1", + "x509-parser", ] [[package]] name = "webrtc-ice" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66eb4b85646f1c52225779db3e1e7e873dede6db68cc9be080b648f1713083a3" +checksum = "4d4f0ca6d4df8d1bdd34eece61b51b62540840b7a000397bcfb53a7bfcf347c8" dependencies = [ "arc-swap", "async-trait", "crc", "log", + "portable-atomic", "rand 0.8.5", "serde", "serde_json", - "stun 0.5.1", + "stun", "thiserror", "tokio", "turn", @@ -6960,27 +6878,27 @@ dependencies = [ "uuid", "waitgroup", "webrtc-mdns", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] name = "webrtc-mdns" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bebbd40e7f8b630a0f1a74783dbfff1edfc0ccaae891c4689891156a8c4d8c" +checksum = "c0804694f3b2acfdff48f6df217979b13cb0a00377c63b5effd111daaee7e8c4" dependencies = [ "log", "socket2 0.5.7", "thiserror", "tokio", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] name = "webrtc-media" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfde3c7b9450b67d466bb2f02c6d9ff9514d33535eb9994942afd1f828839d1" +checksum = "1c15b20e98167b22949abc1c20eca7c6d814307d187068fe7a48f0b87a4f6d46" dependencies = [ "byteorder", "bytes", @@ -6991,26 +6909,27 @@ dependencies = [ [[package]] name = "webrtc-sctp" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1af6116b7f9703560c3ad0b32f67220b171bb1b59633b03563db8404d0e482ea" +checksum = "1d850daa68639b9d7bb16400676e97525d1e52b15b4928240ae2ba0e849817a5" dependencies = [ "arc-swap", "async-trait", "bytes", "crc", "log", + "portable-atomic", "rand 0.8.5", "thiserror", "tokio", - "webrtc-util 0.8.1", + "webrtc-util", ] [[package]] name = "webrtc-srtp" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db1f36c1c81e4b1e531c0b9678ba0c93809e196ce62122d87259bb71c03b9f" +checksum = "fbec5da43a62c228d321d93fb12cc9b4d9c03c9b736b0c215be89d8bd0774cfe" dependencies = [ "aead", "aes", @@ -7026,27 +6945,7 @@ dependencies = [ "subtle", "thiserror", "tokio", - "webrtc-util 0.8.1", -] - -[[package]] -name = "webrtc-util" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e85154ef743d9a2a116d104faaaa82740a281b8b4bed5ee691a2df6c133d873" -dependencies = [ - "async-trait", - "bitflags 1.3.2", - "bytes", - "ipnet", - "lazy_static", - "libc", - "log", - "nix 0.26.4", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", + "webrtc-util", ] [[package]] @@ -7336,24 +7235,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x509-parser" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" -dependencies = [ - "asn1-rs 0.5.2", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "ring 0.16.20", - "rusticata-macros", - "thiserror", - "time", -] - [[package]] name = "x509-parser" version = "0.16.0" @@ -7365,7 +7246,8 @@ dependencies = [ "der-parser 9.0.0", "lazy_static", "nom", - "oid-registry 0.7.0", + "oid-registry", + "ring", "rusticata-macros", "thiserror", "time", diff --git a/Cargo.toml b/Cargo.toml index a3e610ccb14..965b3cb6c01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,7 +130,7 @@ tracing-subscriber = "0.3" futures = "0.3.30" web-time = "1.1.0" ring = "0.17.8" -rcgen = "0.12.1" +rcgen = "0.13.1" [patch.crates-io] diff --git a/transports/tls/src/certificate.rs b/transports/tls/src/certificate.rs index c0e1a043b27..914f97916e1 100644 --- a/transports/tls/src/certificate.rs +++ b/transports/tls/src/certificate.rs @@ -99,24 +99,21 @@ pub fn generate( // Endpoints MAY generate a new key and certificate // for every connection attempt, or they MAY reuse the same key // and certificate for multiple connections. - let certificate_keypair = rcgen::KeyPair::generate(P2P_SIGNATURE_ALGORITHM)?; + let certificate_keypair = rcgen::KeyPair::generate_for(P2P_SIGNATURE_ALGORITHM)?; let rustls_key = rustls::pki_types::PrivateKeyDer::from( rustls::pki_types::PrivatePkcs8KeyDer::from(certificate_keypair.serialize_der()), ); let certificate = { - let mut params = rcgen::CertificateParams::new(vec![]); - params.distinguished_name = rcgen::DistinguishedName::new(); + let mut params = rcgen::CertificateParams::new(vec![])?; params.custom_extensions.push(make_libp2p_extension( identity_keypair, &certificate_keypair, )?); - params.alg = P2P_SIGNATURE_ALGORITHM; - params.key_pair = Some(certificate_keypair); - rcgen::Certificate::from_params(params)? + params.self_signed(&certificate_keypair)? }; - let rustls_certificate = rustls::pki_types::CertificateDer::from(certificate.serialize_der()?); + let rustls_certificate = certificate.der().clone(); Ok((rustls_certificate, rustls_key)) } diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index fc2748d93c3..6f86e200004 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -31,7 +31,7 @@ tinytemplate = "1.2" tokio = { workspace = true, features = ["net"], optional = true } tokio-util = { version = "0.7", features = ["compat"], optional = true } tracing = { workspace = true } -webrtc = { version = "0.9.0", optional = true } +webrtc = { version = "0.11.0", optional = true } [features] tokio = ["dep:tokio", "dep:tokio-util", "dep:webrtc", "if-watch/tokio"] diff --git a/transports/webrtc/src/tokio/certificate.rs b/transports/webrtc/src/tokio/certificate.rs index 81197af4132..2e248d1ec1a 100644 --- a/transports/webrtc/src/tokio/certificate.rs +++ b/transports/webrtc/src/tokio/certificate.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use rand::{distributions::DistString, CryptoRng, Rng}; +use rand::{CryptoRng, Rng}; use webrtc::peer_connection::certificate::RTCCertificate; use crate::tokio::fingerprint::Fingerprint; @@ -37,12 +37,10 @@ impl Certificate { where R: CryptoRng + Rng, { - let mut params = rcgen::CertificateParams::new(vec![ - rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 16) - ]); - params.alg = &rcgen::PKCS_ECDSA_P256_SHA256; + let certificate_keypair = rcgen::KeyPair::generate_for(&rcgen::PKCS_ECDSA_P256_SHA256).unwrap(); + Ok(Self { - inner: RTCCertificate::from_params(params).expect("default params to work"), + inner: RTCCertificate::from_key_pair(certificate_keypair).expect("default params to work"), }) }