v1.0.2
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4,7 +4,7 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "acme-client"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
dependencies = [
|
||||
"acme-lib",
|
||||
"async-std",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "acme-client"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Acme auto challenge client, acme-client can issue certificates from Let's encrypt"
|
||||
|
||||
13
src/main.rs
13
src/main.rs
@@ -56,6 +56,7 @@ struct AcmeRequest<'a> {
|
||||
local_public_ip: Option<&'a str>,
|
||||
key_file: Option<String>,
|
||||
cert_file: Option<String>,
|
||||
outputs_file: Option<String>,
|
||||
}
|
||||
|
||||
#[async_std::main]
|
||||
@@ -76,6 +77,7 @@ async fn main() -> tide::Result<()> {
|
||||
.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("outputs").short("o").long("outputs").takes_value(true).help("Outputs file"))
|
||||
.arg(Arg::with_name("check").long("check").help("Check cert config"))
|
||||
.arg(Arg::with_name("hide-logo").long("hide-logo").help("Hide logo"))
|
||||
.arg(Arg::with_name("skip-verify-ip").short("k").long("skip-verify-ip").help("Skip verify public ip"))
|
||||
@@ -246,6 +248,7 @@ async fn main() -> tide::Result<()> {
|
||||
local_public_ip: local_public_ip.as_deref(),
|
||||
cert_file,
|
||||
key_file,
|
||||
outputs_file: matches.value_of("outputs").map(|s| s.into()),
|
||||
..Default::default()
|
||||
};
|
||||
if let Err(e) = request_acme_certificate(acme_request) {
|
||||
@@ -280,6 +283,7 @@ async fn main() -> tide::Result<()> {
|
||||
local_public_ip: local_public_ip.as_deref(),
|
||||
cert_file: Some(format!("{}/{}", item.path, CERT_NAME)),
|
||||
key_file: Some(format!("{}/{}", item.path, KEY_NAME)),
|
||||
outputs_file: None,
|
||||
};
|
||||
if let Err(e) = request_acme_certificate(acme_request) {
|
||||
failure!("Request certificate: {}, by acme failed: {}", item.path, e);
|
||||
@@ -470,6 +474,15 @@ fn request_acme_certificate(acme_request: AcmeRequest) -> XResult<()> {
|
||||
failure!("Write file: {}, failed: {}", key_file, e);
|
||||
}
|
||||
success!("Write files success: {} and {}", cert_file, key_file);
|
||||
} else if let Some(outputs_file) = &acme_request.outputs_file {
|
||||
let mut outputs = String::new();
|
||||
outputs.push_str("private key:\n");
|
||||
outputs.push_str(cert.private_key());
|
||||
outputs.push_str("\n\ncertificates:\n");
|
||||
outputs.push_str(cert.certificate());
|
||||
if let Err(e) = fs::write(outputs_file, outputs) {
|
||||
failure!("Write file: {}, failed: {}", outputs_file, e);
|
||||
}
|
||||
} else {
|
||||
information!("Certificate key: {}", cert.private_key());
|
||||
information!("Certificate pem: {}", cert.certificate());
|
||||
|
||||
Reference in New Issue
Block a user