From 8099451d22f96130b533569c1042f462a0129deb Mon Sep 17 00:00:00 2001 From: DanGould Date: Mon, 5 Feb 2024 12:41:59 -0500 Subject: [PATCH] Bump rustls v0.22 --- Cargo.lock | 194 ++++++++++++++++++++++++++++------- payjoin-cli/Cargo.toml | 10 +- payjoin-cli/src/app.rs | 18 ++-- payjoin/Cargo.toml | 4 +- payjoin/src/v2.rs | 9 +- payjoin/tests/integration.rs | 6 +- 6 files changed, 182 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8caf765ea..89e28b42c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,14 +62,14 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" dependencies = [ "aead 0.4.3", "aes 0.7.5", "cipher 0.3.0", - "ctr 0.8.0", + "ctr 0.7.0", "ghash 0.4.4", "subtle", ] @@ -665,9 +665,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array", "subtle", @@ -675,9 +675,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.8.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" dependencies = [ "cipher 0.3.0", ] @@ -1184,6 +1184,29 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "hoot" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df22a4d90f1b0e65fe3e0d6ee6a4608cc4d81f4b2eb3e670f44bb6bde711e452" +dependencies = [ + "httparse", + "log", +] + +[[package]] +name = "hootbin" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "354e60868e49ea1a39c44b9562ad207c4259dc6eabf9863bf3b0f058c55cfdb2" +dependencies = [ + "fastrand", + "hoot", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "hpke" version = "0.10.0" @@ -1279,10 +1302,27 @@ dependencies = [ "http", "hyper", "log", - "rustls", - "rustls-native-certs", + "rustls 0.21.10", + "rustls-native-certs 0.6.3", + "tokio", + "tokio-rustls 0.24.1", +] + +[[package]] +name = "hyper-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "399c78f9338483cb7e630c8474b07268983c6bd5acee012e4211f9f7bb21b070" +dependencies = [ + "futures-util", + "http", + "hyper", + "log", + "rustls 0.22.2", + "rustls-native-certs 0.7.0", + "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", ] [[package]] @@ -1293,9 +1333,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1495,9 +1535,9 @@ checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" dependencies = [ "log", "once_cell", - "rustls", - "rustls-webpki", - "webpki-roots", + "rustls 0.21.10", + "rustls-webpki 0.101.7", + "webpki-roots 0.25.3", ] [[package]] @@ -1616,7 +1656,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eef3e1559d017cef55f296e593737811b65106eb822bac13622ed49cbfebcf62" dependencies = [ "aead 0.4.3", - "aes-gcm 0.9.4", + "aes-gcm 0.9.2", "byteorder", "chacha20poly1305 0.8.0", "hex", @@ -1639,7 +1679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578cb11a3fb5c85697ed8bb850d5ad1cbf819d3eea05c2b253cf1d240fbb10c5" dependencies = [ "aead 0.4.3", - "aes-gcm 0.9.4", + "aes-gcm 0.9.2", "byteorder", "chacha20poly1305 0.8.0", "hex", @@ -1743,7 +1783,7 @@ dependencies = [ "log", "ohttp 0.5.1", "rand", - "rustls", + "rustls 0.22.2", "serde", "serde_json", "testcontainers", @@ -1765,11 +1805,11 @@ dependencies = [ "config", "env_logger", "hyper", - "hyper-rustls", + "hyper-rustls 0.25.0", "log", "payjoin", "rcgen", - "rustls", + "rustls 0.22.2", "serde", "tokio", "ureq", @@ -1784,10 +1824,10 @@ dependencies = [ "bhttp 0.4.0", "bitcoin", "hyper", - "hyper-rustls", + "hyper-rustls 0.24.2", "ohttp 0.4.0", "rcgen", - "rustls", + "rustls 0.21.10", "sqlx", "tokio", "tracing", @@ -1917,7 +1957,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures 0.2.12", "opaque-debug", - "universal-hash 0.4.1", + "universal-hash 0.4.0", ] [[package]] @@ -1940,7 +1980,7 @@ dependencies = [ "cfg-if", "cpufeatures 0.2.12", "opaque-debug", - "universal-hash 0.4.1", + "universal-hash 0.4.0", ] [[package]] @@ -2207,10 +2247,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring 0.17.7", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring 0.17.7", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -2218,7 +2272,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", "schannel", "security-framework", ] @@ -2232,6 +2299,22 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a716eb65e3158e90e17cd93d855216e27bde02745ab842f2cab4a39dba1bacf" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -2242,6 +2325,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.7", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "ryu" version = "1.0.16" @@ -2710,9 +2804,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -2911,7 +3005,18 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.2", + "rustls-pki-types", "tokio", ] @@ -3070,9 +3175,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array", "subtle", @@ -3102,26 +3207,28 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.1" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" +checksum = "399dd89e2af196ae4f83a47bb37a1455e664fe2fed97b3ae68a1c4a3f8216e76" dependencies = [ "base64 0.21.7", "flate2", + "hootbin", "log", "once_cell", - "rustls", - "rustls-native-certs", - "rustls-webpki", + "rustls 0.22.2", + "rustls-native-certs 0.7.0", + "rustls-pki-types", + "rustls-webpki 0.102.2", "url", - "webpki-roots", + "webpki-roots 0.26.1", ] [[package]] name = "url" -version = "2.5.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", "idna", @@ -3243,6 +3350,15 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "which" version = "4.4.2" diff --git a/payjoin-cli/Cargo.toml b/payjoin-cli/Cargo.toml index 26e96da89..8b9b981be 100644 --- a/payjoin-cli/Cargo.toml +++ b/payjoin-cli/Cargo.toml @@ -19,7 +19,7 @@ path = "src/main.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] native-certs = ["ureq/native-certs"] -danger-local-https = ["rcgen", "rustls/dangerous_configuration", "hyper-rustls"] +danger-local-https = ["rcgen", "rustls", "hyper-rustls"] v2 = ["payjoin/v2"] [dependencies] @@ -30,15 +30,15 @@ clap = { version = "3.2.22", features = ["derive"] } config = "0.13.3" env_logger = "0.9.0" hyper = { version = "0.14", features = ["full"] } -hyper-rustls = { version = "0.24", optional = true } +hyper-rustls = { version = "0.25", optional = true } log = "0.4.7" payjoin = { version = "0.13.0", features = ["send", "receive", "base64"] } rcgen = { version = "0.11.1", optional = true } -rustls = { version = "0.21.9", optional = true } +rustls = { version = "0.22.2", optional = true } serde = { version = "1.0.160", features = ["derive"] } tokio = { version = "1.12.0", features = ["full"] } -ureq = "2.8.0" -url = "2.2.1" +ureq = "2.9.4" +url = "2.3.1" [dev-dependencies] bitcoind = { version = "0.31.1", features = ["0_21_2"] } diff --git a/payjoin-cli/src/app.rs b/payjoin-cli/src/app.rs index 42123fbcc..515a40a55 100644 --- a/payjoin-cli/src/app.rs +++ b/payjoin-cli/src/app.rs @@ -325,7 +325,7 @@ impl App { use std::io::Write; use hyper::server::conn::AddrIncoming; - use rustls::{Certificate, PrivateKey}; + use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer}; let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_string()])?; let cert_der = cert.serialize_der()?; @@ -333,8 +333,9 @@ impl App { local_cert_path.push(LOCAL_CERT_FILE); let mut file = std::fs::File::create(local_cert_path)?; file.write_all(&cert_der)?; - let key = PrivateKey(cert.serialize_private_key_der()); - let certs = vec![Certificate(cert.serialize_der()?)]; + let key = + PrivateKeyDer::from(PrivatePkcs8KeyDer::from(cert.serialize_private_key_der())); + let certs = vec![CertificateDer::from(cert.serialize_der()?)]; let incoming = AddrIncoming::bind(&bind_addr.into())?; let acceptor = hyper_rustls::TlsAcceptor::builder() .with_single_cert(certs, key) @@ -895,18 +896,17 @@ fn serialize_psbt(psbt: &Psbt) -> String { base64::encode(psbt.serialize()) } #[cfg(feature = "danger-local-https")] fn http_agent() -> Result { use rustls::client::ClientConfig; - use rustls::{Certificate, RootCertStore}; + use rustls::pki_types::CertificateDer; + use rustls::RootCertStore; use ureq::AgentBuilder; let mut local_cert_path = std::env::temp_dir(); local_cert_path.push(LOCAL_CERT_FILE); let cert_der = std::fs::read(local_cert_path)?; let mut root_cert_store = RootCertStore::empty(); - root_cert_store.add(&Certificate(cert_der))?; - let client_config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(root_cert_store) - .with_no_client_auth(); + root_cert_store.add(CertificateDer::from(cert_der.as_slice()))?; + let client_config = + ClientConfig::builder().with_root_certificates(root_cert_store).with_no_client_auth(); Ok(AgentBuilder::new().tls_config(Arc::new(client_config)).build()) } diff --git a/payjoin/Cargo.toml b/payjoin/Cargo.toml index 1df194cd4..70ab9bbb3 100644 --- a/payjoin/Cargo.toml +++ b/payjoin/Cargo.toml @@ -35,11 +35,11 @@ serde_json = "1.0.108" [dev-dependencies] bitcoind = { version = "0.31.1", features = ["0_21_2"] } env_logger = "0.9.0" -rustls = "0.21.9" +rustls = "0.22.2" testcontainers = "0.15.0" testcontainers-modules = { version = "0.1.3", features = ["postgres"] } tokio = { version = "1.12.0", features = ["full"] } -ureq = "2.8.0" +ureq = "2.9.4" [package.metadata.docs.rs] features = ["send", "receive", "base64", "v2"] diff --git a/payjoin/src/v2.rs b/payjoin/src/v2.rs index 096df0065..2d4a39dc1 100644 --- a/payjoin/src/v2.rs +++ b/payjoin/src/v2.rs @@ -193,10 +193,17 @@ pub fn ohttp_encapsulate( ) -> Result<(Vec, ohttp::ClientResponse), Error> { let ctx = ohttp::ClientRequest::from_config(ohttp_keys)?; let url = url::Url::parse(target_resource)?; + let authority_bytes = url.host().map_or_else(Vec::new, |host| { + let mut authority = host.to_string(); + if let Some(port) = url.port() { + authority.push_str(&format!(":{}", port)); + } + authority.into_bytes() + }); let mut bhttp_message = bhttp::Message::request( method.as_bytes().to_vec(), url.scheme().as_bytes().to_vec(), - url.authority().as_bytes().to_vec(), + authority_bytes, url.path().as_bytes().to_vec(), ); if let Some(body) = body { diff --git a/payjoin/tests/integration.rs b/payjoin/tests/integration.rs index d5aaea44d..4209cc816 100644 --- a/payjoin/tests/integration.rs +++ b/payjoin/tests/integration.rs @@ -620,7 +620,8 @@ mod integration { fn http_agent() -> ureq::Agent { use rustls::client::ClientConfig; - use rustls::{Certificate, RootCertStore}; + use rustls::pki_types::CertificateDer; + use rustls::RootCertStore; use ureq::AgentBuilder; let mut local_cert_path = std::env::temp_dir(); @@ -628,9 +629,8 @@ mod integration { println!("TEST CERT PATH {:?}", &local_cert_path); let cert_der = std::fs::read(local_cert_path).unwrap(); let mut root_cert_store = RootCertStore::empty(); - root_cert_store.add(&Certificate(cert_der)).unwrap(); + root_cert_store.add(CertificateDer::from(cert_der.as_slice())).unwrap(); let client_config = ClientConfig::builder() - .with_safe_defaults() .with_root_certificates(root_cert_store) .with_no_client_auth();