Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commit 9198284263 #626

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions crates/ironrdp-server/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
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::<Result<Vec<_>, _>>()
.with_context(|| format!("collecting server cert `{cert_path:?}`"))?
} else {
certs(&mut BufReader::new(File::open(cert_path)?))
}
.collect::<Result<_, _>>()
.context(format!("reading server cert `{cert_path:?}`"))?;
certs(&mut BufReader::new(
File::open(cert_path).with_context(|| format!("opening server cert `{cert_path:?}`"))?,
))
.collect::<Result<Vec<_>, _>>()
.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()
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion xtask/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");

Expand Down
Loading