Skip to content

Commit

Permalink
Connect to ssh-agent in a sync way
Browse files Browse the repository at this point in the history
Signed-off-by: xphoniex <[email protected]>
  • Loading branch information
xphoniex committed Sep 26, 2022
1 parent 56b602d commit ef98163
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/sign/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ impl SshAgent {
S: ClientStream + Unpin,
{
match &self.path {
None => Ok(S::connect_env().await?),
Some(path) => Ok(S::connect_uds(path).await?),
None => Ok(S::connect_env()?),
Some(path) => Ok(S::connect_uds(path)?),
}
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ where
{
let mut client = agent.client::<S>().await?;
let secret = ed25519::SigningKey::from(secret);
client.add_identity(&secret, constraints).await?;
client.add_identity(&secret, constraints)?;

Ok(())
}
Expand All @@ -171,7 +171,7 @@ where
S: ClientStream + Unpin,
{
let mut client = agent.client::<S>().await?;
let keys = client.remove_identity(key).await?;
let keys = client.remove_identity(key)?;
Ok(keys)
}

Expand All @@ -180,7 +180,7 @@ where
S: ClientStream + Unpin,
{
let mut client = agent.client::<S>().await?;
let keys = client.request_identities().await?;
let keys = client.request_identities()?;
Ok(keys)
}

Expand All @@ -198,11 +198,11 @@ where
async fn sign(&self, data: &[u8]) -> Result<ed25519::Signature, Self::Error> {
let mut guard = self.client.lock().await;
let client = match guard.take() {
None => ClientStream::connect_env().await?,
None => ClientStream::connect_env()?,
Some(client) => client,
};

let (client, sig) = client.sign_request_signature(&self.rfc, data).await;
let (client, sig) = client.sign_request_signature(&self.rfc, data);
*guard = Some(client);
Ok(sig?)
}
Expand Down

0 comments on commit ef98163

Please sign in to comment.