Let's encrypt email address as parameter
This commit is contained in:
parent
8a4778c6bc
commit
090e58ca7c
2 changed files with 12 additions and 3 deletions
|
@ -18,18 +18,20 @@ use crate::proxy_config::*;
|
|||
|
||||
pub struct CertStore {
|
||||
consul: Consul,
|
||||
letsencrypt_email: String,
|
||||
certs: RwLock<HashMap<String, Arc<Cert>>>,
|
||||
self_signed_certs: RwLock<HashMap<String, Arc<Cert>>>,
|
||||
rx_proxy_config: watch::Receiver<Arc<ProxyConfig>>,
|
||||
}
|
||||
|
||||
impl CertStore {
|
||||
pub fn new(consul: Consul, rx_proxy_config: watch::Receiver<Arc<ProxyConfig>>) -> Arc<Self> {
|
||||
pub fn new(consul: Consul, rx_proxy_config: watch::Receiver<Arc<ProxyConfig>>, letsencrypt_email: String) -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
consul,
|
||||
certs: RwLock::new(HashMap::new()),
|
||||
self_signed_certs: RwLock::new(HashMap::new()),
|
||||
rx_proxy_config,
|
||||
letsencrypt_email,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -157,7 +159,7 @@ impl CertStore {
|
|||
// ---- Do let's encrypt stuff ----
|
||||
|
||||
let dir = Directory::from_url(DirectoryUrl::LetsEncrypt)?;
|
||||
let contact = vec!["mailto:alex@adnab.me".to_string()];
|
||||
let contact = vec![format!("mailto:{}", self.letsencrypt_email)];
|
||||
|
||||
let acc =
|
||||
if let Some(acc_privkey) = self.consul.kv_get("letsencrypt_account_key.pem").await? {
|
||||
|
|
|
@ -52,6 +52,13 @@ struct Opt {
|
|||
default_value = "0.0.0.0:443"
|
||||
)]
|
||||
pub https_bind_addr: SocketAddr,
|
||||
|
||||
/// E-mail address for Let's Encrypt certificate requests
|
||||
#[structopt(
|
||||
long = "letsencrypt-email",
|
||||
env = "TRICOT_LETSENCRYPT_EMAIL",
|
||||
)]
|
||||
pub letsencrypt_email: String,
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
|
||||
|
@ -68,7 +75,7 @@ async fn main() {
|
|||
let consul = consul::Consul::new(&opt.consul_addr, &opt.consul_kv_prefix, &opt.node_name);
|
||||
let mut rx_proxy_config = proxy_config::spawn_proxy_config_task(consul.clone());
|
||||
|
||||
let cert_store = cert_store::CertStore::new(consul.clone(), rx_proxy_config.clone());
|
||||
let cert_store = cert_store::CertStore::new(consul.clone(), rx_proxy_config.clone(), opt.letsencrypt_email.clone());
|
||||
tokio::spawn(cert_store.clone().watch_proxy_config());
|
||||
|
||||
tokio::spawn(http::serve_http(opt.http_bind_addr, consul.clone()));
|
||||
|
|
Loading…
Reference in a new issue