mirror of
https://codeberg.org/tyy/aspm
synced 2025-01-10 12:19:29 -07:00
Fix pkcs#8 conversion for P-256 keys
This commit is contained in:
parent
bb6bed5531
commit
ec1b9f3bf9
4 changed files with 75 additions and 66 deletions
|
@ -67,7 +67,7 @@ impl JwtExt for Jwk {
|
||||||
// 4. Convert that Pkey into the PKCS#8 encoded private key (and then base64 encode it)
|
// 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() {
|
let key_pair: Box<dyn KeyPair> = match self.key_type() {
|
||||||
"EC" => match self.curve() {
|
"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"),
|
_ => bail!("Unsupported curve type"),
|
||||||
},
|
},
|
||||||
"OKP" => match self.curve() {
|
"OKP" => match self.curve() {
|
||||||
|
|
|
@ -2,15 +2,15 @@ use anstyle::{AnsiColor, Color as AnstyleColor, Reset, Style as Anstyle};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use asp::keys::AspKeyType;
|
use asp::keys::AspKeyType;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use dialoguer::{Confirm, theme::ColorfulTheme, console::Term};
|
use dialoguer::{console::Term, theme::ColorfulTheme, Confirm};
|
||||||
use indoc::writedoc;
|
use indoc::writedoc;
|
||||||
use sea_orm::ModelTrait;
|
use sea_orm::ModelTrait;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
commands::{AspmSubcommand, KeysEntityExt, KeysQueryResult},
|
||||||
entities::keys::{Entity as KeysEntity, Model as KeysModel},
|
entities::keys::{Entity as KeysEntity, Model as KeysModel},
|
||||||
commands::{AspmSubcommand, KeysQueryResult, KeysEntityExt}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Deletes a saved key, after asking for confirmation.
|
/// Deletes a saved key, after asking for confirmation.
|
||||||
|
@ -90,7 +90,9 @@ impl AspmSubcommand for KeysDeleteCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
let fingerprint = key.fingerprint.clone();
|
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);
|
println!("Successfully deleted key with fingerprint {}", fingerprint);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
pub mod delete;
|
||||||
pub mod export;
|
pub mod export;
|
||||||
pub mod generate;
|
pub mod generate;
|
||||||
#[cfg(feature = "gpg-compat")]
|
#[cfg(feature = "gpg-compat")]
|
||||||
pub mod import_gpg;
|
pub mod import_gpg;
|
||||||
pub mod list;
|
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.
|
/// A subcommand to allow the management of keys, which can then be used to create, modify, or delete profiles.
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
|
|
|
@ -87,7 +87,14 @@ fn main() {
|
||||||
if let Err(e) = cli(parsed) {
|
if let Err(e) = cli(parsed) {
|
||||||
match verbose {
|
match verbose {
|
||||||
true => {
|
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}"),
|
false => eprintln!("An error occurred while running that command:\n{e}"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue