chore: fix warn
This commit is contained in:
@@ -2,14 +2,12 @@ use serde::{Deserialize, Serialize};
|
||||
use rust_util::util_file;
|
||||
use rust_util::XResult;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use acme_lib::DirectoryUrl;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use crate::x509;
|
||||
use crate::x509::{X509PublicKeyAlgo, X509EcPublicKeyAlgo, X509Certificate};
|
||||
use std::time::{SystemTime, Duration};
|
||||
use std::time::SystemTime;
|
||||
|
||||
pub const CERT_NAME: &str = "cert.pem";
|
||||
pub const KEY_NAME: &str = "key.pem";
|
||||
@@ -29,9 +27,9 @@ impl Default for AcmeAlgo {
|
||||
}
|
||||
|
||||
impl AcmeAlgo {
|
||||
pub fn parse_or_default(s: &str) -> AcmeAlgo {
|
||||
Self::parse(s).unwrap_or_else(|_| Default::default())
|
||||
}
|
||||
// pub fn parse_or_default(s: &str) -> AcmeAlgo {
|
||||
// Self::parse(s).unwrap_or_else(|_| Default::default())
|
||||
// }
|
||||
|
||||
pub fn parse(s: &str) -> XResult<AcmeAlgo> {
|
||||
match s {
|
||||
@@ -59,9 +57,9 @@ impl Default for AcmeMode {
|
||||
}
|
||||
|
||||
impl AcmeMode {
|
||||
pub fn parse_or_default(s: &str) -> AcmeMode {
|
||||
Self::parse(s).unwrap_or_else(|_| Default::default())
|
||||
}
|
||||
// pub fn parse_or_default(s: &str) -> AcmeMode {
|
||||
// Self::parse(s).unwrap_or_else(|_| Default::default())
|
||||
// }
|
||||
|
||||
pub fn parse(s: &str) -> XResult<AcmeMode> {
|
||||
match s {
|
||||
@@ -90,17 +88,17 @@ pub struct AcmeConfig {
|
||||
}
|
||||
|
||||
impl AcmeConfig {
|
||||
pub fn get_auth_timeout(&self) -> u64 {
|
||||
self.auth_timeout.unwrap_or(5_000)
|
||||
}
|
||||
|
||||
pub fn get_csr_timeout(&self) -> u64 {
|
||||
self.csr_timeout.unwrap_or(5_000)
|
||||
}
|
||||
|
||||
pub fn get_concurrent(&self) -> u32 {
|
||||
self.concurrent.unwrap_or(0)
|
||||
}
|
||||
// pub fn get_auth_timeout(&self) -> u64 {
|
||||
// self.auth_timeout.unwrap_or(5_000)
|
||||
// }
|
||||
//
|
||||
// pub fn get_csr_timeout(&self) -> u64 {
|
||||
// self.csr_timeout.unwrap_or(5_000)
|
||||
// }
|
||||
//
|
||||
// pub fn get_concurrent(&self) -> u32 {
|
||||
// self.concurrent.unwrap_or(0)
|
||||
// }
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
@@ -194,10 +192,10 @@ impl CertConfigItem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_acme_config(file: Option<&str>, load_default: bool) -> XResult<AcmeConfig> {
|
||||
pub fn load_acme_config(file: Option<&str>, load_default: bool) -> XResult<Option<AcmeConfig>> {
|
||||
if let Some(file) = file {
|
||||
let s = opt_result!(util_file::read_file_content(file), "Read file: {}, failed: {}", file);
|
||||
return Ok(opt_result!(deser_hjson::from_str(&s), "Parse acme config file: {}, failed: {}", file));
|
||||
return Ok(Some(opt_result!(deser_hjson::from_str(&s), "Parse acme config file: {}, failed: {}", file)));
|
||||
}
|
||||
|
||||
if load_default {
|
||||
@@ -207,9 +205,9 @@ pub fn load_acme_config(file: Option<&str>, load_default: bool) -> XResult<AcmeC
|
||||
]);
|
||||
if let Some(default_config) = default_config {
|
||||
let s = opt_result!(fs::read_to_string(default_config.clone()), "Read file: {:?}, failed: {}", default_config);
|
||||
return Ok(opt_result!(deser_hjson::from_str(&s), "Parse acme config file: {:?}, failed: {}", default_config));
|
||||
return Ok(Some(opt_result!(deser_hjson::from_str(&s), "Parse acme config file: {:?}, failed: {}", default_config)));
|
||||
}
|
||||
}
|
||||
|
||||
simple_error!("Acme config file not found!")
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ mod x509;
|
||||
// mod simple_thread_pool;
|
||||
|
||||
use rust_util::XResult;
|
||||
use acme_lib::{DirectoryUrl, Directory};
|
||||
use acme_lib::Directory;
|
||||
use acme_lib::{create_p384_key, create_p256_key, create_rsa_key};
|
||||
use acme_lib::persist::FilePersist;
|
||||
use clap::{App, Arg};
|
||||
@@ -23,7 +23,7 @@ use async_std::channel;
|
||||
use async_std::channel::Sender;
|
||||
use config::AcmeAlgo;
|
||||
use config::AcmeMode;
|
||||
use crate::config::{CertConfig, CERT_NAME, KEY_NAME};
|
||||
use crate::config::{CertConfig, CERT_NAME, KEY_NAME, load_acme_config};
|
||||
|
||||
const NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
@@ -137,6 +137,10 @@ async fn main() -> tide::Result<()> {
|
||||
|
||||
// TODO ......
|
||||
let config = matches.value_of("config");
|
||||
let _acme_config = load_acme_config(config, true).unwrap_or_else(|e| {
|
||||
failure!("Load acme config failed: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let cert_config = matches.value_of("cert-config");
|
||||
match cert_config {
|
||||
|
||||
@@ -5,9 +5,8 @@ use x509_parser::extensions::{ParsedExtension, GeneralName};
|
||||
use x509_parser::der_parser::oid::Oid;
|
||||
use std::str::FromStr;
|
||||
use rust_util::XResult;
|
||||
use x509_parser::der_parser::der::parse_der_bitstring;
|
||||
use x509_parser::der_parser::parse_der;
|
||||
use x509_parser::x509::{AlgorithmIdentifier, SubjectPublicKeyInfo};
|
||||
use x509_parser::x509::SubjectPublicKeyInfo;
|
||||
use x509_parser::der_parser::ber::BerObjectContent;
|
||||
|
||||
lazy_static! {
|
||||
@@ -120,7 +119,7 @@ pub fn parse_x509(pem_id: &str, pem: &str) -> XResult<X509Certificate> {
|
||||
Some(common_name) => common_name.to_string(),
|
||||
};
|
||||
let mut alt_names = vec![];
|
||||
for (oid, ext) in cert.extensions().iter() {
|
||||
for (_oid, ext) in cert.extensions().iter() {
|
||||
if let ParsedExtension::SubjectAlternativeName(san) = ext.parsed_extension() {
|
||||
for name in &san.general_names {
|
||||
match name {
|
||||
|
||||
Reference in New Issue
Block a user