diff --git a/acmed/src/certificate.rs b/acmed/src/certificate.rs index 89f4410..4d399cb 100644 --- a/acmed/src/certificate.rs +++ b/acmed/src/certificate.rs @@ -185,6 +185,8 @@ impl Certificate { key_type: self.key_type.to_string(), status: status.to_string(), is_success, + certificate_path: crate::storage::get_certificate_path(&self.file_manager).await?, + private_key_path: crate::storage::get_keypair_path(&self.file_manager).await?, env: HashMap::new(), }; hook_data.set_env(&self.env); diff --git a/acmed/src/hooks.rs b/acmed/src/hooks.rs index 626ef02..8ebcff1 100644 --- a/acmed/src/hooks.rs +++ b/acmed/src/hooks.rs @@ -48,6 +48,8 @@ pub struct PostOperationHookData { pub key_type: String, pub status: String, pub is_success: bool, + pub certificate_path: PathBuf, + pub private_key_path: PathBuf, pub env: HashMap, } diff --git a/acmed/src/storage.rs b/acmed/src/storage.rs index 0896a69..f501d8d 100644 --- a/acmed/src/storage.rs +++ b/acmed/src/storage.rs @@ -244,8 +244,12 @@ pub async fn set_account_data(fm: &FileManager, data: &[u8]) -> Result<(), Error write_file(fm, FileType::Account, data).await } +pub async fn get_keypair_path(fm: &FileManager) -> Result { + get_file_path(fm, FileType::PrivateKey) +} + pub async fn get_keypair(fm: &FileManager) -> Result { - let path = get_file_path(fm, FileType::PrivateKey)?; + let path = get_keypair_path(&fm).await?; let raw_key = read_file(fm, &path).await?; let key = KeyPair::from_pem(&raw_key)?; Ok(key) @@ -256,8 +260,12 @@ pub async fn set_keypair(fm: &FileManager, key_pair: &KeyPair) -> Result<(), Err write_file(fm, FileType::PrivateKey, &data).await } +pub async fn get_certificate_path(fm: &FileManager) -> Result { + get_file_path(fm, FileType::Certificate) +} + pub async fn get_certificate(fm: &FileManager) -> Result { - let path = get_file_path(fm, FileType::Certificate)?; + let path = get_certificate_path(&fm).await?; let raw_crt = read_file(fm, &path).await?; let crt = X509Certificate::from_pem(&raw_crt)?; Ok(crt) diff --git a/man/en/acmed.toml.5 b/man/en/acmed.toml.5 index 35b6ba6..bb7286f 100644 --- a/man/en/acmed.toml.5 +++ b/man/en/acmed.toml.5 @@ -585,6 +585,10 @@ True if the certificate request is successful. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair. .It Cm status Ar string Human-readable status. If the certificate request failed, it contains the error description. +.It Cm certificate_path Ar string +Path to the file containing the certificate. +.It Cm private_key_path Ar string +Path to the file containing the private key. .El .El .Sh DEFAULT HOOKS