blob: c1007b4471b6cba691588606c42bdb7b4fbed395 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use super::error::CertError;
use crate::command::Command;
use tedge_config::*;
use tedge_utils::paths::ok_if_not_found;
/// Remove the device certificate
pub struct RemoveCertCmd {
/// The path of the certificate to be removed
pub cert_path: FilePath,
/// The path of the private key to be removed
pub key_path: FilePath,
}
impl Command for RemoveCertCmd {
fn description(&self) -> String {
"remove the device certificate".into()
}
fn execute(&self) -> anyhow::Result<()> {
self.remove_certificate()?;
Ok(())
}
}
impl RemoveCertCmd {
fn remove_certificate(&self) -> Result<(), CertError> {
std::fs::remove_file(&self.cert_path).or_else(ok_if_not_found)?;
std::fs::remove_file(&self.key_path).or_else(ok_if_not_found)?;
Ok(())
}
}
|