use super::{super::std::immutable::*, container::*, error::*};
use {
rustls_acme::{caches::*, *},
std::{io, path::*},
};
pub use acme::{LETS_ENCRYPT_PRODUCTION_DIRECTORY, LETS_ENCRYPT_STAGING_DIRECTORY};
impl TlsContainer {
pub fn add_resolver_from_acme(&mut self, acme: ACME) -> Result<(), TlsContainerError> {
let hosts = acme.hosts.clone();
let state = acme.into_config().state();
let resolver = state.resolver();
for host in hosts {
self.add_delegate(host.clone(), resolver.clone())?;
}
Ok(())
}
}
#[derive(Debug, Default)]
pub struct ACME {
pub hosts: Vec<ImmutableString>,
pub directory: ImmutableString,
pub contacts: Vec<ImmutableString>,
pub cache: PathBuf,
}
impl ACME {
pub fn into_config(self) -> AcmeConfig<io::Error> {
let mut acme_config = AcmeConfig::new(self.hosts).directory(self.directory).cache(DirCache::new(self.cache));
for contact in self.contacts {
acme_config = acme_config.contact_push(String::from("mailto:") + &contact);
}
acme_config
}
}