Browse Source

Merge pull request #96 from jcgruenhage/post-operation-expose-file-paths

Expose file paths to post-operation hook
pull/85/merge
Rodolphe Bréard 2 years ago
committed by GitHub
parent
commit
761c0a72c0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      acmed/src/certificate.rs
  2. 2
      acmed/src/hooks.rs
  3. 12
      acmed/src/storage.rs
  4. 4
      man/en/acmed.toml.5

2
acmed/src/certificate.rs

@ -185,6 +185,8 @@ impl Certificate {
key_type: self.key_type.to_string(), key_type: self.key_type.to_string(),
status: status.to_string(), status: status.to_string(),
is_success, 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(), env: HashMap::new(),
}; };
hook_data.set_env(&self.env); hook_data.set_env(&self.env);

2
acmed/src/hooks.rs

@ -48,6 +48,8 @@ pub struct PostOperationHookData {
pub key_type: String, pub key_type: String,
pub status: String, pub status: String,
pub is_success: bool, pub is_success: bool,
pub certificate_path: PathBuf,
pub private_key_path: PathBuf,
pub env: HashMap<String, String>, pub env: HashMap<String, String>,
} }

12
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 write_file(fm, FileType::Account, data).await
} }
pub async fn get_keypair_path(fm: &FileManager) -> Result<PathBuf, Error> {
get_file_path(fm, FileType::PrivateKey)
}
pub async fn get_keypair(fm: &FileManager) -> Result<KeyPair, Error> { pub async fn get_keypair(fm: &FileManager) -> Result<KeyPair, Error> {
let path = get_file_path(fm, FileType::PrivateKey)?;
let path = get_keypair_path(&fm).await?;
let raw_key = read_file(fm, &path).await?; let raw_key = read_file(fm, &path).await?;
let key = KeyPair::from_pem(&raw_key)?; let key = KeyPair::from_pem(&raw_key)?;
Ok(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 write_file(fm, FileType::PrivateKey, &data).await
} }
pub async fn get_certificate_path(fm: &FileManager) -> Result<PathBuf, Error> {
get_file_path(fm, FileType::Certificate)
}
pub async fn get_certificate(fm: &FileManager) -> Result<X509Certificate, Error> { pub async fn get_certificate(fm: &FileManager) -> Result<X509Certificate, Error> {
let path = get_file_path(fm, FileType::Certificate)?;
let path = get_certificate_path(&fm).await?;
let raw_crt = read_file(fm, &path).await?; let raw_crt = read_file(fm, &path).await?;
let crt = X509Certificate::from_pem(&raw_crt)?; let crt = X509Certificate::from_pem(&raw_crt)?;
Ok(crt) Ok(crt)

4
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. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair.
.It Cm status Ar string .It Cm status Ar string
Human-readable status. If the certificate request failed, it contains the error description. 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
.El .El
.Sh DEFAULT HOOKS .Sh DEFAULT HOOKS

Loading…
Cancel
Save