credence_lib/configuration/port/
acme.rs1use super::super::error::*;
2
3use {
4 compris::resolve::*,
5 kutil::{
6 cli::depict::*,
7 http::tls::{ACME as KutilACME, *},
8 std::immutable::*,
9 },
10 std::path::*,
11};
12
13#[derive(Clone, Debug, Depict, Resolve)]
19pub struct ACME {
20 #[resolve]
22 #[depict(style(string))]
23 pub directory: ByteString,
24
25 #[resolve(required)]
27 #[depict(iter(item), style(string))]
28 pub contacts: Vec<ByteString>,
29
30 #[resolve]
32 #[depict(as(debug), style(string))]
33 pub cache: PathBuf,
34}
35
36impl ACME {
37 pub fn validate<PathT>(&mut self, base_path: PathT) -> Result<(), ConfigurationError>
39 where
40 PathT: AsRef<Path>,
41 {
42 if !self.cache.is_absolute() {
43 self.cache = base_path.as_ref().join(&self.cache);
44 }
45
46 Ok(())
47 }
48
49 pub fn provider(&self, host: ByteString) -> KutilACME {
51 KutilACME {
52 hosts: vec![host],
53 directory: self.directory.clone(),
54 contacts: self.contacts.clone(),
55 cache: self.cache.clone(),
56 }
57 }
58}
59
60impl Default for ACME {
61 fn default() -> Self {
62 Self { directory: LETS_ENCRYPT_STAGING_DIRECTORY.into(), contacts: Default::default(), cache: "acme".into() }
63 }
64}