feat: add arg --cert-dir
This commit is contained in:
14
src/main.rs
14
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) {
|
||||
|
||||
Reference in New Issue
Block a user