Do not store public keys
This commit is contained in:
parent
af9ebfb9e5
commit
85cce35d59
1 changed files with 6 additions and 10 deletions
16
src/keys.rs
16
src/keys.rs
|
|
@ -54,10 +54,11 @@ pub(crate) fn get_keys(machine: Option<&PathBuf>) -> Result<WireguardKeyPair, an
|
|||
hostname = PathBuf::from(gethostname());
|
||||
&hostname
|
||||
};
|
||||
let key_path = get_data_dir().join("keys").join(machine_subdir);
|
||||
let key_path = get_data_dir().join("keys");
|
||||
debug!("key path = {:?}", &key_path);
|
||||
std::fs::create_dir_all(&key_path)?;
|
||||
let private_key_path = key_path.join("key");
|
||||
|
||||
let private_key_path = key_path.join(machine_subdir);
|
||||
let private_key = if private_key_path.is_file() {
|
||||
Key::load(&private_key_path)?
|
||||
} else {
|
||||
|
|
@ -65,14 +66,9 @@ pub(crate) fn get_keys(machine: Option<&PathBuf>) -> Result<WireguardKeyPair, an
|
|||
key.save(&private_key_path)?;
|
||||
key
|
||||
};
|
||||
let public_key_path = key_path.join("pubkey");
|
||||
let public_key = if public_key_path.is_file() {
|
||||
Key::load(&public_key_path)?
|
||||
} else {
|
||||
let key = generate_public_key(&private_key);
|
||||
key.save(&public_key_path)?;
|
||||
key
|
||||
};
|
||||
|
||||
let public_key = generate_public_key(&private_key);
|
||||
|
||||
Ok(WireguardKeyPair {
|
||||
private_key,
|
||||
public_key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue