I have prepared a patch to make the doctests and examples for the
current version of rust-hyper-rustls build with the new rustls-pemfile.

diff -Nru rust-hyper-rustls-0.24.2/debian/changelog 
rust-hyper-rustls-0.24.2/debian/changelog
--- rust-hyper-rustls-0.24.2/debian/changelog   2025-02-07 07:05:33.000000000 
+0000
+++ rust-hyper-rustls-0.24.2/debian/changelog   2025-02-25 00:49:17.000000000 
+0000
@@ -1,3 +1,10 @@
+rust-hyper-rustls (0.24.2-5.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add patch to support rustls-pemfile 2.
+
+ -- Peter Michael Green <plugw...@debian.org>  Tue, 25 Feb 2025 00:49:17 +0000
+
 rust-hyper-rustls (0.24.2-5) unstable; urgency=medium
 
   * stop mention dh-cargo in long description
diff -Nru rust-hyper-rustls-0.24.2/debian/control 
rust-hyper-rustls-0.24.2/debian/control
--- rust-hyper-rustls-0.24.2/debian/control     2025-02-07 07:04:15.000000000 
+0000
+++ rust-hyper-rustls-0.24.2/debian/control     2025-02-25 00:47:02.000000000 
+0000
@@ -16,7 +16,7 @@
  librust-rustls-0.21+logging-dev,
  librust-rustls-0.21+tls12-dev,
  librust-rustls-native-certs-0.6+default-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
diff -Nru rust-hyper-rustls-0.24.2/debian/patches/2005_rustls-pemfile.patch 
rust-hyper-rustls-0.24.2/debian/patches/2005_rustls-pemfile.patch
--- rust-hyper-rustls-0.24.2/debian/patches/2005_rustls-pemfile.patch   
1970-01-01 00:00:00.000000000 +0000
+++ rust-hyper-rustls-0.24.2/debian/patches/2005_rustls-pemfile.patch   
2025-02-25 00:49:17.000000000 +0000
@@ -0,0 +1,98 @@
+Description: support newer version of rustls-pemfile.
+ This patch is based on code changes extracted from
+ 
https://github.com/rustls/hyper-rustls/commit/5d9d4b58a6dd71091a5073cf3db3201f303d8f07
+ adapted by Peter Michael Green to match the types used in this version of the 
crate.
+Author: Peter Michael Green <plugw...@debian.org>
+Author: Dirkjan Ochtman <dirk...@ochtman.nl>
+Forwarded: not-needed
+Last-Update: 2025-02-25
+Index: rust-hyper-rustls-0.24.2/Cargo.toml
+===================================================================
+--- rust-hyper-rustls-0.24.2.orig/Cargo.toml
++++ rust-hyper-rustls-0.24.2/Cargo.toml
+@@ -23,7 +23,7 @@ futures-util = { version = "0.3", defaul
+ [dev-dependencies]
+ hyper = { version = "0.14", features = ["full"] }
+ rustls = { version = "0.21.0", default-features = false, features = ["tls12"] 
}
+-rustls-pemfile = "1.0.0"
++rustls-pemfile = "2.0.0"
+ tokio = { version = "1.0", features = ["io-std", "macros", "net", 
"rt-multi-thread"] }
+ 
+ [features]
+Index: rust-hyper-rustls-0.24.2/examples/client.rs
+===================================================================
+--- rust-hyper-rustls-0.24.2.orig/examples/client.rs
++++ rust-hyper-rustls-0.24.2/examples/client.rs
+@@ -47,8 +47,7 @@ async fn run_client() -> io::Result<()>
+     let tls = match ca {
+         Some(ref mut rd) => {
+             // Read trust roots
+-            let certs = rustls_pemfile::certs(rd)
+-                .map_err(|_| error("failed to load custom CA store".into()))?;
++            let certs = rustls_pemfile::certs(rd).collect::<Result<Vec<_>, 
_>>()?;
+             let mut roots = RootCertStore::empty();
+             roots.add_parsable_certificates(&certs);
+             // TLS client config using the custom CA store for lookups
+Index: rust-hyper-rustls-0.24.2/examples/server.rs
+===================================================================
+--- rust-hyper-rustls-0.24.2.orig/examples/server.rs
++++ rust-hyper-rustls-0.24.2/examples/server.rs
+@@ -87,12 +87,7 @@ fn load_certs(filename: &str) -> io::Res
+     let mut reader = io::BufReader::new(certfile);
+ 
+     // Load and return certificate.
+-    let certs = rustls_pemfile::certs(&mut reader)
+-        .map_err(|_| error("failed to load certificate".into()))?;
+-    Ok(certs
+-        .into_iter()
+-        .map(rustls::Certificate)
+-        .collect())
++    rustls_pemfile::certs(&mut reader).map(|result| result.map(|cert| 
rustls::Certificate(cert.to_vec()))).collect()
+ }
+ 
+ // Load private key from file.
+@@ -103,11 +98,5 @@ fn load_private_key(filename: &str) -> i
+     let mut reader = io::BufReader::new(keyfile);
+ 
+     // Load and return a single private key.
+-    let keys = rustls_pemfile::rsa_private_keys(&mut reader)
+-        .map_err(|_| error("failed to load private key".into()))?;
+-    if keys.len() != 1 {
+-        return Err(error("expected a single private key".into()));
+-    }
+-
+-    Ok(rustls::PrivateKey(keys[0].clone()))
++    rustls_pemfile::private_key(&mut reader).map(|key| 
rustls::PrivateKey(key.unwrap().secret_der().to_vec()))
+ }
+Index: rust-hyper-rustls-0.24.2/src/lib.rs
+===================================================================
+--- rust-hyper-rustls-0.24.2.orig/src/lib.rs
++++ rust-hyper-rustls-0.24.2/src/lib.rs
+@@ -47,16 +47,14 @@
+ //! let mut reader = io::BufReader::new(certfile);
+ //!
+ //! // Load and return certificate.
+-//! let certs = rustls_pemfile::certs(&mut reader).unwrap();
+-//! let certs = certs.into_iter().map(rustls::Certificate).collect();
++//! let certs = rustls_pemfile::certs(&mut reader).map(|result| 
result.map(|cert| rustls::Certificate(cert.to_vec()))).collect::<Result<Vec<_>, 
_>>().unwrap();
+ //!
+ //! // Load private key. (see `examples/server.rs`)
+ //! let keyfile = File::open("examples/sample.rsa").unwrap();
+ //! let mut reader = io::BufReader::new(keyfile);
+ //!
+ //! // Load and return a single private key.
+-//! let keys = rustls_pemfile::rsa_private_keys(&mut reader).unwrap();
+-//! let key = rustls::PrivateKey(keys[0].clone());
++//! let key = rustls_pemfile::private_key(&mut reader).unwrap().unwrap();
+ //! let https = hyper_rustls::HttpsConnectorBuilder::new()
+ //!     .with_native_roots()
+ //!     .https_only()
+@@ -65,7 +63,7 @@
+ //!
+ //! let incoming = AddrIncoming::bind(&addr).unwrap();
+ //! let acceptor = TlsAcceptor::builder()
+-//!     .with_single_cert(certs, key).unwrap()
++//!     .with_single_cert(certs, 
rustls::PrivateKey(key.secret_der().to_vec())).unwrap()
+ //!     .with_all_versions_alpn()
+ //!     .with_incoming(incoming);
+ //! let service = make_service_fn(|_| async { Ok::<_, 
io::Error>(service_fn(|_req|async {Ok::<_, 
io::Error>(Response::new(Body::empty()))})) });
diff -Nru rust-hyper-rustls-0.24.2/debian/patches/series 
rust-hyper-rustls-0.24.2/debian/patches/series
--- rust-hyper-rustls-0.24.2/debian/patches/series      2023-12-15 
20:46:41.000000000 +0000
+++ rust-hyper-rustls-0.24.2/debian/patches/series      2025-02-25 
00:18:10.000000000 +0000
@@ -2,3 +2,4 @@
 1002_test-requires-runtime.patch
 2001_webpki-roots.patch
 2004_tests_broken.patch
+2005_rustls-pemfile.patch
diff -Nru rust-hyper-rustls-0.24.2/debian/tests/control 
rust-hyper-rustls-0.24.2/debian/tests/control
--- rust-hyper-rustls-0.24.2/debian/tests/control       2024-07-30 
16:09:57.000000000 +0000
+++ rust-hyper-rustls-0.24.2/debian/tests/control       2025-02-25 
00:47:54.000000000 +0000
@@ -9,7 +9,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -26,7 +26,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -43,7 +43,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+default-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -60,7 +60,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+http1-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -78,7 +78,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+http2-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -96,7 +96,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+logging-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -114,7 +114,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+native-tokio-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -132,7 +132,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+tls12-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,
@@ -150,7 +150,7 @@
  librust-hyper-0.14+full-dev,
  librust-hyper-rustls-0.24+tokio-runtime-dev,
  librust-rustls-0.21+tls12-dev,
- librust-rustls-pemfile-1+default-dev,
+ librust-rustls-pemfile-2+default-dev,
  librust-tokio-1+default-dev,
  librust-tokio-1+io-std-dev,
  librust-tokio-1+macros-dev,

Reply via email to