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