diff --git a/apps/desktop/desktop_native/ssh_agent/src/protocol/requests.rs b/apps/desktop/desktop_native/ssh_agent/src/protocol/requests.rs index 2f0bda89646..f7204010c5f 100644 --- a/apps/desktop/desktop_native/ssh_agent/src/protocol/requests.rs +++ b/apps/desktop/desktop_native/ssh_agent/src/protocol/requests.rs @@ -161,7 +161,7 @@ impl TryFrom<&[u8]> for SshSignRequest { .map_err(|e| anyhow::anyhow!("Failed to read flags from sign request: {e}"))?; Ok(SshSignRequest { - public_key: PublicKey::from_blob(public_key_blob), + public_key: PublicKey::try_from_blob(public_key_blob)?, payload_to_sign: data.clone(), parsed_sign_request: data.as_slice().try_into()?, flags, diff --git a/apps/desktop/desktop_native/ssh_agent/src/protocol/types.rs b/apps/desktop/desktop_native/ssh_agent/src/protocol/types.rs index 8f1d307af61..bc89615a992 100644 --- a/apps/desktop/desktop_native/ssh_agent/src/protocol/types.rs +++ b/apps/desktop/desktop_native/ssh_agent/src/protocol/types.rs @@ -360,11 +360,12 @@ impl PublicKey { Ok(PublicKey { alg, blob }) } - pub fn from_blob(blob: Vec) -> Self { + pub fn try_from_blob(blob: Vec) -> Result { // Parse the blob to extract the algorithm let mut bytes = &blob[..]; - let alg = String::from_utf8_lossy(read_bytes(&mut bytes).unwrap().as_slice()).to_string(); - PublicKey { alg, blob } + let alg = String::from_utf8_lossy(read_bytes(&mut bytes) + .map_err(|e| anyhow::anyhow!("Failed to read algorithm from blob: {e}"))?.as_slice()).to_string(); + Ok(PublicKey { alg, blob }) } }