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 = PathBuf::from(gethostname());
|
||||||
&hostname
|
&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);
|
debug!("key path = {:?}", &key_path);
|
||||||
std::fs::create_dir_all(&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() {
|
let private_key = if private_key_path.is_file() {
|
||||||
Key::load(&private_key_path)?
|
Key::load(&private_key_path)?
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -65,14 +66,9 @@ pub(crate) fn get_keys(machine: Option<&PathBuf>) -> Result<WireguardKeyPair, an
|
||||||
key.save(&private_key_path)?;
|
key.save(&private_key_path)?;
|
||||||
key
|
key
|
||||||
};
|
};
|
||||||
let public_key_path = key_path.join("pubkey");
|
|
||||||
let public_key = if public_key_path.is_file() {
|
let public_key = generate_public_key(&private_key);
|
||||||
Key::load(&public_key_path)?
|
|
||||||
} else {
|
|
||||||
let key = generate_public_key(&private_key);
|
|
||||||
key.save(&public_key_path)?;
|
|
||||||
key
|
|
||||||
};
|
|
||||||
Ok(WireguardKeyPair {
|
Ok(WireguardKeyPair {
|
||||||
private_key,
|
private_key,
|
||||||
public_key,
|
public_key,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue