Skip to content

Commit

Permalink
Handle pubkey blob in sign call being SSH cert
Browse files Browse the repository at this point in the history
  • Loading branch information
timweri committed Nov 28, 2023
1 parent 2b41dc9 commit 49f3acf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rustica-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,15 @@ impl SshAgentHandler for Handler {

return Ok(Response::SignResponse { signature });
} else if let Signatory::Direct(privkey) = &self.signatory {
// Extract the pubkey fingerprint from either the SSH pubkey or the SSH cert
let fingerprint = match (Certificate::from_bytes(&pubkey), PublicKey::from_bytes(&pubkey)) {
(Ok(cert), _) => cert.key.fingerprint(),
(_, Ok(pubkey)) => pubkey.fingerprint(),
_ => return Err(AgentError::from("Invalid key blob")),
};

// Don't sign requests if the requested key does not match the signatory
if privkey.pubkey.encode() != pubkey {
if privkey.pubkey.fingerprint() != fingerprint {
return Err(AgentError::from("No such key"));
}

Expand Down

0 comments on commit 49f3acf

Please sign in to comment.