feat: email
This commit is contained in:
@@ -150,11 +150,14 @@ impl CertConfigItem {
|
|||||||
}
|
}
|
||||||
cert_dns_names.push(x509_certificate.common_name.to_lowercase());
|
cert_dns_names.push(x509_certificate.common_name.to_lowercase());
|
||||||
|
|
||||||
self.dns_names.as_ref().map(|dns_names| dns_names.iter().map(|n| n.to_lowercase()).map(|n| {
|
if let Some(dns_names) = &self.dns_names {
|
||||||
if !self_dns_names.contains(&n) {
|
for n in dns_names {
|
||||||
self_dns_names.push(n);
|
let n = n.to_lowercase();
|
||||||
|
if !self_dns_names.contains(&n) {
|
||||||
|
self_dns_names.push(n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
for n in &x509_certificate.alt_names {
|
for n in &x509_certificate.alt_names {
|
||||||
let n = n.to_lowercase();
|
let n = n.to_lowercase();
|
||||||
if !cert_dns_names.contains(&n) {
|
if !cert_dns_names.contains(&n) {
|
||||||
|
|||||||
41
src/main.rs
41
src/main.rs
@@ -26,6 +26,7 @@ use async_std::channel::Sender;
|
|||||||
use config::AcmeMode;
|
use config::AcmeMode;
|
||||||
use crate::config::{CertConfig, CERT_NAME, KEY_NAME};
|
use crate::config::{CertConfig, CERT_NAME, KEY_NAME};
|
||||||
use crate::x509::{X509PublicKeyAlgo, X509EcPublicKeyAlgo};
|
use crate::x509::{X509PublicKeyAlgo, X509EcPublicKeyAlgo};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
const NAME: &str = env!("CARGO_PKG_NAME");
|
const NAME: &str = env!("CARGO_PKG_NAME");
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
@@ -86,10 +87,37 @@ async fn main() -> tide::Result<()> {
|
|||||||
|
|
||||||
debugging!("Clap matches: {:?}", matches);
|
debugging!("Clap matches: {:?}", matches);
|
||||||
|
|
||||||
let email = matches.value_of("email").unwrap_or_else(|| {
|
let account_dir = matches.value_of("dir").unwrap_or("acme_dir");
|
||||||
failure!("Email is not assigned.");
|
|
||||||
exit(1);
|
let mut account_email = PathBuf::from(account_dir);
|
||||||
});
|
account_email.push("account_email.conf");
|
||||||
|
|
||||||
|
let email = if account_email.exists() {
|
||||||
|
match fs::read_to_string(&account_email) {
|
||||||
|
Err(e) => {
|
||||||
|
failure!("Read from file: {:?}, failed: {}", account_email, e);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
Ok(email) => {
|
||||||
|
if let Some(email_from_args) = matches.value_of("email") {
|
||||||
|
if &email != email_from_args {
|
||||||
|
warning!("Get email from account config: {}", email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
email.trim().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let email = matches.value_of("email").unwrap_or_else(|| {
|
||||||
|
failure!("Email is not assigned.");
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
information!("Write email to account config: {:?}", account_email);
|
||||||
|
fs::write(account_email, email);
|
||||||
|
|
||||||
|
email.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
match matches.value_of("type") {
|
match matches.value_of("type") {
|
||||||
Some("http") => {}
|
Some("http") => {}
|
||||||
@@ -138,7 +166,6 @@ async fn main() -> tide::Result<()> {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let account_dir = matches.value_of("dir").unwrap_or("acme_dir");
|
|
||||||
|
|
||||||
let check = matches.is_present("check");
|
let check = matches.is_present("check");
|
||||||
|
|
||||||
@@ -161,7 +188,7 @@ async fn main() -> tide::Result<()> {
|
|||||||
let alt_names: Vec<&str> = domains.into_iter().skip(1).collect();
|
let alt_names: Vec<&str> = domains.into_iter().skip(1).collect();
|
||||||
information!("Domains, main: {}, alt: {:?}", primary_name, alt_names);
|
information!("Domains, main: {}, alt: {:?}", primary_name, alt_names);
|
||||||
let acme_request = AcmeRequest {
|
let acme_request = AcmeRequest {
|
||||||
contract_email: email,
|
contract_email: &email,
|
||||||
primary_name,
|
primary_name,
|
||||||
alt_names: &alt_names,
|
alt_names: &alt_names,
|
||||||
algo,
|
algo,
|
||||||
@@ -197,7 +224,7 @@ async fn main() -> tide::Result<()> {
|
|||||||
information!("Domains, main: {}, alt: {:?}", common_name, dns_names);
|
information!("Domains, main: {}, alt: {:?}", common_name, dns_names);
|
||||||
let alt_names: Vec<&str> = dns_names.iter().map(|n| n.as_str()).collect();
|
let alt_names: Vec<&str> = dns_names.iter().map(|n| n.as_str()).collect();
|
||||||
let acme_request = AcmeRequest {
|
let acme_request = AcmeRequest {
|
||||||
contract_email: email,
|
contract_email: &email,
|
||||||
primary_name: common_name,
|
primary_name: common_name,
|
||||||
alt_names: &alt_names,
|
alt_names: &alt_names,
|
||||||
algo,
|
algo,
|
||||||
|
|||||||
Reference in New Issue
Block a user