Skip to content

Commit

Permalink
fix: fix commit 9198284 (#626)
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-André Lureau <[email protected]>
Changelog: ignore
  • Loading branch information
elmarco authored Jan 6, 2025
1 parent 236a132 commit a0d32d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
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

0 comments on commit a0d32d7

Please sign in to comment.