diff --git a/examples/hello_world_tls/Cargo.toml b/examples/hello_world_tls/Cargo.toml index 4532d052..b9daafa1 100644 --- a/examples/hello_world_tls/Cargo.toml +++ b/examples/hello_world_tls/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [dependencies] gotham = { path = "../../gotham", features = ["rustls"] } -rustls-pemfile = "1.0" +rustls-pemfile = "2.1" diff --git a/examples/hello_world_tls/src/main.rs b/examples/hello_world_tls/src/main.rs index e7678f40..96fd264f 100644 --- a/examples/hello_world_tls/src/main.rs +++ b/examples/hello_world_tls/src/main.rs @@ -1,6 +1,6 @@ //! A Hello World example application for working with Gotham. use gotham::anyhow; -use gotham::rustls::{self, Certificate, PrivateKey, ServerConfig}; +use gotham::rustls::{Certificate, PrivateKey, ServerConfig}; use gotham::state::State; use rustls_pemfile::{certs, pkcs8_private_keys}; use std::io::BufReader; @@ -24,19 +24,19 @@ pub fn main() -> anyhow::Result<()> { Ok(()) } -fn build_config() -> Result { +fn build_config() -> anyhow::Result { let mut cert_file = BufReader::new(&include_bytes!("cert.pem")[..]); let mut key_file = BufReader::new(&include_bytes!("key.pem")[..]); let certs = certs(&mut cert_file) - .unwrap() - .into_iter() - .map(Certificate) - .collect(); - let mut keys = pkcs8_private_keys(&mut key_file).unwrap(); + .map(|result| result.map(|der| Certificate(der.to_vec()))) + .collect::>()?; + let mut keys = pkcs8_private_keys(&mut key_file); + let key = PrivateKey(keys.next().unwrap()?.secret_pkcs8_der().to_vec()); ServerConfig::builder() .with_safe_defaults() .with_no_client_auth() - .with_single_cert(certs, PrivateKey(keys.remove(0))) + .with_single_cert(certs, key) + .map_err(Into::into) } #[cfg(test)]