Fundamentum client v0.5.0
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//! Asks the running Custos for a subkey cert, as a Domi app would.
|
||||
//!
|
||||
//! `cargo run -p custos-local --example request_subkey -- <app_id> [purpose] [app name]`
|
||||
|
||||
use tessera::{Id, match_code};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let app_id = Id::new(args.first().map(String::as_str).unwrap_or("demo")).expect("an app id: a-z, 0-9, '-'");
|
||||
let purpose = Id::new(args.get(1).map(String::as_str).unwrap_or("sync")).expect("a purpose: a-z, 0-9, '-'");
|
||||
let app = args.get(2).cloned().unwrap_or_else(|| format!("{app_id} (request_subkey example)"));
|
||||
|
||||
let run = || -> Result<(), custos_local::LocalError> {
|
||||
let mut custos = custos_local::Custos::connect()?;
|
||||
let subkey = custos.subkey(&app, &app_id)?;
|
||||
println!("subkey {}", subkey.public());
|
||||
println!("match {} <- Custos shows the same code", match_code(&subkey.public()));
|
||||
let cert = custos.request_cert(&app, &app_id, &purpose, &subkey)?;
|
||||
println!("root {}", cert.root());
|
||||
println!("app {} / {}", cert.app_id(), cert.purpose());
|
||||
println!("valid {} .. {} (Unix seconds)", cert.not_before(), cert.not_after());
|
||||
println!("cert {}", cert.to_text());
|
||||
Ok(())
|
||||
};
|
||||
if let Err(e) = run() {
|
||||
eprintln!("error: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user