1
0
Fork 0
mirror of https://codeberg.org/tyy/aspm synced 2024-12-22 20:39:29 -07:00

Fix pkcs#8 conversion for P-256 keys

This commit is contained in:
Tyler Beckman 2023-08-02 19:30:45 -06:00
parent bb6bed5531
commit ec1b9f3bf9
Signed by: Ty
GPG key ID: 2813440C772555A4
4 changed files with 75 additions and 66 deletions

View file

@ -67,7 +67,7 @@ impl JwtExt for Jwk {
// 4. Convert that Pkey into the PKCS#8 encoded private key (and then base64 encode it)
let key_pair: Box<dyn KeyPair> = match self.key_type() {
"EC" => match self.curve() {
Some("p-256") => Box::new(EcKeyPair::from_jwk(self)?),
Some("P-256") => Box::new(EcKeyPair::from_jwk(self)?),
_ => bail!("Unsupported curve type"),
},
"OKP" => match self.curve() {

View file

@ -2,15 +2,15 @@ use anstyle::{AnsiColor, Color as AnstyleColor, Reset, Style as Anstyle};
use anyhow::Context;
use asp::keys::AspKeyType;
use clap::Parser;
use dialoguer::{Confirm, theme::ColorfulTheme, console::Term};
use dialoguer::{console::Term, theme::ColorfulTheme, Confirm};
use indoc::writedoc;
use sea_orm::ModelTrait;
use std::io::Write;
use crate::{
commands::{AspmSubcommand, KeysEntityExt, KeysQueryResult},
entities::keys::{Entity as KeysEntity, Model as KeysModel},
commands::{AspmSubcommand, KeysQueryResult, KeysEntityExt}
};
/// Deletes a saved key, after asking for confirmation.
@ -90,7 +90,9 @@ impl AspmSubcommand for KeysDeleteCommand {
}
let fingerprint = key.fingerprint.clone();
key.delete(&state.db).await.context("Unable to delete key")?;
key.delete(&state.db)
.await
.context("Unable to delete key")?;
println!("Successfully deleted key with fingerprint {}", fingerprint);
Ok(())

View file

@ -1,11 +1,11 @@
use clap::{Parser, Subcommand};
pub mod delete;
pub mod export;
pub mod generate;
#[cfg(feature = "gpg-compat")]
pub mod import_gpg;
pub mod list;
pub mod delete;
/// A subcommand to allow the management of keys, which can then be used to create, modify, or delete profiles.
#[derive(Parser)]

View file

@ -87,7 +87,14 @@ fn main() {
if let Err(e) = cli(parsed) {
match verbose {
true => {
eprintln!("An error occurred while running that command:\n{e:?}");
eprintln!(
"An error occurred while running that command:\n{e:?}\nStack:\n{stack}",
stack = e
.chain()
.map(|entry| format!("\t- {entry}"))
.collect::<Vec<_>>()
.join("\n")
);
}
false => eprintln!("An error occurred while running that command:\n{e}"),
}