Skip to content

Commit

Permalink
feat: add CLI arg to add public key to keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
gotlougit committed Oct 26, 2023
1 parent e05b298 commit ba31b10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ fn write_config(
Ok(())
}

pub fn add_trusted_key(config_path: &str, key: Vec<u8>) -> Result<()> {
pub fn add_trusted_key(key: Vec<u8>) -> Result<()> {
let config_path = get_config_path();
let mut conf = get_all_vars().unwrap();
conf.trusted_keys.push(key);
let encoded_public_key = general_purpose::STANDARD.encode(conf.public_key);
Expand All @@ -69,7 +70,7 @@ pub fn add_trusted_key(config_path: &str, key: Vec<u8>) -> Result<()> {
.collect();

write_config(
config_path,
&config_path,
&encoded_public_key,
&encoded_private_key,
encoded_trusted_keys,
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ async fn main() -> Result<()> {
crate::client::run_client(sock, server_addr, &filename, &auth, trusted_keys)
.await?;
}
Command::AddKey { key: _ } => {
todo!();
Command::AddKey { key } => {
let decoded_key = general_purpose::STANDARD.decode(key)?;
crate::config::add_trusted_key(decoded_key)?;
}
};
}
Expand Down

0 comments on commit ba31b10

Please sign in to comment.