summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko <heiko@schaefer.name>2021-04-27 15:51:47 +0200
committerHeiko <heiko@schaefer.name>2021-04-27 15:51:47 +0200
commit41fd6957c092730ad2a4cef7353aded040c7f337 (patch)
tree17620f8c05f3ee9149d264be90b1937af7fc1f74
parente0991cb90533e9d6128f21c0eb725439bc88410d (diff)
downloadopenpgp-ca-41fd6957c092730ad2a4cef7353aded040c7f337.tar.gz
Cleanup.
-rw-r--r--src/bin.rs45
-rw-r--r--src/cli.rs4
2 files changed, 27 insertions, 22 deletions
diff --git a/src/bin.rs b/src/bin.rs
index 3e1fe4e..1ba0c6d 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -7,15 +7,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
use anyhow::Result;
-
-use openpgp_ca_lib::ca::OpenpgpCa;
+use structopt::StructOpt;
pub mod cli;
-fn main() -> Result<()> {
- use cli::*;
- use structopt::StructOpt;
+use cli::*;
+use openpgp_ca_lib::ca::OpenpgpCa;
+fn main() -> Result<()> {
let cli = Cli::from_args();
let ca = OpenpgpCa::new(cli.database.as_deref())?;
@@ -29,10 +28,16 @@ fn main() -> Result<()> {
} => {
// TODO: key-profile?
- let email: Vec<&str> =
+ let emails: Vec<_> =
email.iter().map(String::as_str).collect();
- ca.user_new(name.as_deref(), &email[..], None, true, minimal)?;
+ ca.user_new(
+ name.as_deref(),
+ &emails[..],
+ None,
+ true,
+ minimal,
+ )?;
}
UserCommand::AddRevocation { revocation_file } => {
ca.revocation_add_from_file(&revocation_file)?
@@ -47,26 +52,27 @@ fn main() -> Result<()> {
}
},
UserCommand::Import {
- key_file,
+ cert_file,
name,
email,
revocation_file,
} => {
- let key = std::fs::read_to_string(key_file)?;
- let mut revoc_certs: Vec<String> = Vec::new();
- for filename in revocation_file {
- let rev = std::fs::read_to_string(filename)?;
+ let cert = std::fs::read_to_string(cert_file)?;
+
+ let mut revoc_certs = Vec::new();
+ for path in revocation_file {
+ let rev = std::fs::read_to_string(path)?;
revoc_certs.push(rev);
}
- let email: Vec<&str> =
+ let emails: Vec<_> =
email.iter().map(String::as_str).collect();
ca.cert_import_new(
- &key,
+ &cert,
revoc_certs,
name.as_deref(),
- &email[..],
+ &emails,
None,
)?;
}
@@ -91,16 +97,15 @@ fn main() -> Result<()> {
ca.secret().ca_init(&domain, name.as_deref())?;
}
CaCommand::Export => {
- let ca_key = ca.ca_get_pubkey_armored()?;
- println!("{}", ca_key);
+ println!("{}", ca.ca_get_pubkey_armored()?);
}
CaCommand::Revocations { output } => {
ca.secret().ca_generate_revocations(output)?;
println!("Wrote a set of revocations to the output file");
}
- CaCommand::ImportTsig { key_file } => {
- let key = std::fs::read_to_string(key_file)?;
- ca.secret().ca_import_tsig(&key)?;
+ CaCommand::ImportTsig { cert_file } => {
+ let cert = std::fs::read_to_string(cert_file)?;
+ ca.secret().ca_import_tsig(&cert)?;
}
CaCommand::Show => ca.ca_show()?,
},
diff --git a/src/cli.rs b/src/cli.rs
index c9831b6..5fa0d76 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -86,7 +86,7 @@ pub enum CaCommand {
/// Import trust signature for CA Key
ImportTsig {
#[structopt(help = "File that contains the tsigned CA Key")]
- key_file: PathBuf,
+ cert_file: PathBuf,
},
/// Show CA
Show,
@@ -148,7 +148,7 @@ pub enum UserCommand {
long = "key-file",
help = "File that contains the User's Public Key"
)]
- key_file: PathBuf,
+ cert_file: PathBuf,
#[structopt(
short = "n",