diff --git a/crates/ironrdp-server/src/helper.rs b/crates/ironrdp-server/src/helper.rs index 68a7a9a58..644fa797d 100644 --- a/crates/ironrdp-server/src/helper.rs +++ b/crates/ironrdp-server/src/helper.rs @@ -21,16 +21,21 @@ impl TlsIdentityCtx { /// /// The file format can be either PEM (if the file extension ends with .pem) or DER. pub fn init_from_paths(cert_path: &Path, key_path: &Path) -> anyhow::Result { - let certs: Vec<_> = if cert_path.extension().map_or(false, |ext| ext == "pem") { + let certs = if cert_path.extension().map_or(false, |ext| ext == "pem") { CertificateDer::pem_file_iter(cert_path) + .with_context(|| format!("reading server cert `{cert_path:?}`"))? + .collect::, _>>() + .with_context(|| format!("collecting server cert `{cert_path:?}`"))? } else { - certs(&mut BufReader::new(File::open(cert_path)?)) - } - .collect::>() - .context(format!("reading server cert `{cert_path:?}`"))?; + certs(&mut BufReader::new( + File::open(cert_path).with_context(|| format!("opening server cert `{cert_path:?}`"))?, + )) + .collect::, _>>() + .with_context(|| format!("collecting server cert `{cert_path:?}`"))? + }; let priv_key = if key_path.extension().map_or(false, |ext| ext == "pem") { - PrivateKeyDer::from_pem_file(key_path).context("reading server key `{key_path:?}`")? + PrivateKeyDer::from_pem_file(key_path).with_context(|| format!("reading server key `{key_path:?}`"))? } else { pkcs8_private_keys(&mut BufReader::new(File::open(key_path)?)) .next() @@ -42,7 +47,7 @@ impl TlsIdentityCtx { use x509_cert::der::Decode as _; let cert = certs.first().ok_or_else(|| std::io::Error::other("invalid cert"))?; - let cert = x509_cert::Certificate::from_der(&cert).map_err(std::io::Error::other)?; + let cert = x509_cert::Certificate::from_der(cert).map_err(std::io::Error::other)?; cert.tbs_certificate .subject_public_key_info .subject_public_key diff --git a/xtask/src/check.rs b/xtask/src/check.rs index 27700825f..0efce96d6 100644 --- a/xtask/src/check.rs +++ b/xtask/src/check.rs @@ -18,7 +18,11 @@ pub fn lints(sh: &Shell) -> anyhow::Result<()> { let _s = Section::new("LINTS"); // TODO: when 1.74 is released use `--keep-going`: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#keep-going - cmd!(sh, "{CARGO} clippy --workspace --all-targets --locked -- -D warnings").run()?; + cmd!( + sh, + "{CARGO} clippy --workspace --all-targets --features helper --locked -- -D warnings" + ) + .run()?; println!("All good!");