feat: command line supports dns challenge
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4,7 +4,7 @@ version = 3
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "acme-client"
|
name = "acme-client"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"acme-lib",
|
"acme-lib",
|
||||||
"aliyun-openapi-core-rust-sdk",
|
"aliyun-openapi-core-rust-sdk",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "acme-client"
|
name = "acme-client"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Acme auto challenge client, acme-client can issue certificates from Let's encrypt"
|
description = "Acme auto challenge client, acme-client can issue certificates from Let's encrypt"
|
||||||
|
|||||||
@@ -24,6 +24,17 @@ impl Default for AcmeChallenge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AcmeChallenge {
|
||||||
|
pub fn from_str(t: Option<&str>) -> Self {
|
||||||
|
let t = t.map(|t| t.to_ascii_lowercase()).unwrap_or_else(|| "http".to_string());
|
||||||
|
if t == "dns" {
|
||||||
|
AcmeChallenge::Dns
|
||||||
|
} else {
|
||||||
|
AcmeChallenge::Http
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum AcmeMode {
|
pub enum AcmeMode {
|
||||||
Prod,
|
Prod,
|
||||||
@@ -135,12 +146,7 @@ impl CertConfig {
|
|||||||
|
|
||||||
impl CertConfigItem {
|
impl CertConfigItem {
|
||||||
pub fn get_acme_challenge(&self) -> AcmeChallenge {
|
pub fn get_acme_challenge(&self) -> AcmeChallenge {
|
||||||
let t = self.r#type.as_ref().map(|t| t.to_ascii_lowercase()).unwrap_or_else(|| "http".to_string());
|
AcmeChallenge::from_str(self.r#type.as_ref().map(|s| s.as_str()))
|
||||||
if t == "dns" {
|
|
||||||
AcmeChallenge::Dns
|
|
||||||
} else {
|
|
||||||
AcmeChallenge::Http
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill_dns_names(&mut self) -> XResult<Option<X509Certificate>> {
|
pub fn fill_dns_names(&mut self) -> XResult<Option<X509Certificate>> {
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ async fn main() -> tide::Result<()> {
|
|||||||
.arg(Arg::with_name("skip-verify-ip").short("k").long("skip-verify-ip").help("Skip verify public ip"))
|
.arg(Arg::with_name("skip-verify-ip").short("k").long("skip-verify-ip").help("Skip verify public ip"))
|
||||||
.arg(Arg::with_name("skip-verify-certificate").short("K").long("skip-verify-certificate").help("Skip verify certificate"))
|
.arg(Arg::with_name("skip-verify-certificate").short("K").long("skip-verify-certificate").help("Skip verify certificate"))
|
||||||
.arg(Arg::with_name("allow-interact").long("allow-interact").help("Allow interact"))
|
.arg(Arg::with_name("allow-interact").long("allow-interact").help("Allow interact"))
|
||||||
|
.arg(Arg::with_name("challenge-type").short("T").long("challenge-type").takes_value(true).default_value("http").help("Challenge type, http or dns"))
|
||||||
|
.arg(Arg::with_name("dns-supplier").short("s").long("dns-supplier").takes_value(true).default_value("account://***:****@**?id=*").help("DNS supplier"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
if matches.is_present("verbose") {
|
if matches.is_present("verbose") {
|
||||||
@@ -249,8 +251,8 @@ async fn main() -> tide::Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let acme_request = AcmeRequest {
|
let acme_request = AcmeRequest {
|
||||||
challenge: AcmeChallenge::Http,
|
challenge: AcmeChallenge::from_str(matches.value_of("challenge-type")),
|
||||||
credential_supplier: None,
|
credential_supplier: matches.value_of("dns-supplier"),
|
||||||
allow_interact: false,
|
allow_interact: false,
|
||||||
contract_email: &email,
|
contract_email: &email,
|
||||||
primary_name,
|
primary_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user