Skip to content

Commit

Permalink
fix(cli): do not panic if private key password is wrong, closes #3449 (
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 17, 2022
1 parent 53e4dd8 commit 17f17a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-private-key-pwd-panic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Do not panic if the updater private key password is wrong.
8 changes: 6 additions & 2 deletions tooling/cli/src/helpers/updater_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use anyhow::Context;
use base64::{decode, encode};
use minisign::{sign, KeyPair as KP, SecretKeyBox};
use std::{
Expand Down Expand Up @@ -109,8 +110,11 @@ where
P: AsRef<Path>,
{
let decoded_secret = decode_key(private_key)?;
let sk_box = SecretKeyBox::from_string(&decoded_secret).unwrap();
let sk = sk_box.into_secret_key(password).unwrap();
let sk_box = SecretKeyBox::from_string(&decoded_secret)
.with_context(|| "failed to load updater private key")?;
let sk = sk_box
.into_secret_key(password)
.with_context(|| "incorrect updater private key password")?;

// We need to append .sig at the end it's where the signature will be stored
let signature_path_string = format!("{}.sig", bin_path.as_ref().display());
Expand Down

0 comments on commit 17f17a8

Please sign in to comment.