From ee17791b57b01b938c832ef0b4f2c227133a272b Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 4 Sep 2021 00:41:13 +0800 Subject: [PATCH] feat: add arg --cert-dir --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1295ea6..37eef21 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,6 +69,7 @@ async fn main() -> tide::Result<()> { .arg(Arg::with_name("timeout").long("timeout").takes_value(true).default_value("5000").help("Timeout (ms)")) .arg(Arg::with_name("mode").short("m").long("mode").takes_value(true).default_value("prod").help("Mode")) .arg(Arg::with_name("dir").long("dir").takes_value(true).default_value("acme_dir").help("Account key dir")) + .arg(Arg::with_name("cert-dir").long("cert-dir").takes_value(true).help("Certificate dir")) .arg(Arg::with_name("config").short("c").long("config").takes_value(true).help("Cert config")) .arg(Arg::with_name("check").long("check").help("Check cert config")) .arg(Arg::with_name("hide-logo").long("hide-logo").help("Hide logo")) @@ -209,6 +210,17 @@ async fn main() -> tide::Result<()> { let primary_name = domains[0]; let alt_names: Vec<&str> = domains.into_iter().skip(1).collect(); information!("Domains, main: {}, alt: {:?}", primary_name, alt_names); + + let (cert_file, key_file) = match matches.value_of("cert-dir") { + None => (None, None), + Some(cert_dir) => { + information!("Certificate output dir: {}", cert_dir); + fs::create_dir_all(cert_dir).ok(); + (Some(format!("{}/{}", cert_dir, CERT_NAME)), + Some(format!("{}/{}", cert_dir, KEY_NAME))) + } + }; + let acme_request = AcmeRequest { contract_email: &email, primary_name, @@ -218,6 +230,8 @@ async fn main() -> tide::Result<()> { account_dir, timeout, local_public_ip: local_public_ip.as_deref(), + cert_file, + key_file, ..Default::default() }; if let Err(e) = request_acme_certificate(acme_request) {